from dataclasses import field from tempfile import tempdir import firebase_admin from firebase_admin import credentials from firebase_admin import db from find_s1_image import find_img_value import pandas as pd import statsmodels.api as sm import seaborn as sns sns.set() import numpy as np from sklearn.cluster import KMeans from find_study_area_values import find_study_area_values from make_area_estimate_image import make_area_estimate_image from sentinelhub import WebFeatureService, BBox, CRS, DataSource, MimeType, CRS, BBox, WmsRequest,DataCollection cred = credentials.Certificate('servicekey.json') x = 0.0002 y = 0.0002 fromdate = '20220701' todate = '20220715' s1_images = ['IW-VH-DB'] s2_images = [] # s1_images = ["B02", "B03", "B04", "B05"] #s2_images = ["RVI-NEW"] try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') study_uid = "vPM6EKWHfHRxmRfc0YJ7PZ8J9tR2" gt_uid = ['u5ZgAskSltX7dQdNFUlHsgVhAlf2', 'b2j92LjidjeGt2b60QHhSj4GeS63'] different_gt_uid = 'hxA3VYEFpaOluurIbHxdzd4gPlw1' study_field_id = '1662365839021' gt_fields = {} for temp_id in gt_uid: temp_gt_fields = db.reference('PaidMonitoredFields').child('PMF').child(temp_id).get() for(p,q) in temp_gt_fields.items(): gt_fields[p] = q json_obj = {} json_obj["type"] = "FeatureCollection" json_obj["features"] = [] for (fieldid, fieldobj) in gt_fields.items(): pointsObj = fieldobj["Coordinates"] single_geometry_obj = {} single_geometry_obj["type"] = "Feature" single_geometry_obj["geometry"] = {} single_geometry_obj["geometry"]["type"] = "LineString" singleFieldPointsArr = [] for (pointkey, pointobj) in pointsObj.items(): pointArr = [pointobj["Longitude"], pointobj["Latitude"]] singleFieldPointsArr.append(pointArr) single_geometry_obj["geometry"]["coordinates"] = singleFieldPointsArr json_obj["features"].append(single_geometry_obj)