from tempfile import tempdir import firebase_admin from firebase_admin import credentials from firebase_admin import db from find_s1_image2 import find_img_value import pandas as pd import statsmodels.api as sm import seaborn as sns sns.set() import time import json 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 import json import xlsxwriter import datetime from sentinelhub import WebFeatureService, BBox, CRS, DataSource, MimeType, CRS, BBox, WmsRequest,DataCollection cred = credentials.Certificate('servicekey.json') x = 0.0003 y = 0.0003 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') workbook = xlsxwriter.Workbook('bhumitantra.xlsx') worksheet = workbook.add_worksheet() uids = ['AvlbNpsuI7P1sva1NWMBUN4Fmbg1','2Gpn5tspykcKPt0tQqkQrpT52Ji2', 'DgwGhWlZKndMe33MlmSnt2Vp0PD2', 'JNH5nfMdqDOQGrTOM0wrVysxgH92'] main_arr = [] row = 1 main_arr.append(['Name & Phone Number', 'Coordinates']) worksheet.write(0,0,'Name & Phone Number') worksheet.write(0,1,'Coordinates') for uid in uids: all_fields = db.reference('PaidMonitoredFields').child('PMF').child(uid).get() try: for (fieldid, fieldobj) in all_fields.items(): db.reference('PaidMonitoredFields').child('PMF').child(uid).child(fieldid).child('Paused').set('yes') time.sleep(0.1) # pointsObj = fieldobj["Coordinates"] # midlat, midlng, pointNum = 0,0,0 # for (point_key, point_obj) in pointsObj.items(): # lat = point_obj["Latitude"] # lng = point_obj["Longitude"] # midlat = midlat + lat # midlng = midlng + lng # pointNum = pointNum + 1 # midlat = midlat/pointNum # midlng = midlng/pointNum # field_address = fieldobj["FieldAddress"] # worksheet.write(row, 0, field_address) # worksheet.write(row, 1, (str(midlat) + ', ' + str(midlng))) # worksheet.write(row, 2, fieldid) # main_arr.append([field_address, (str(midlat) + ', ' + str(midlng))]) # row = row + 1 except: awa = 1 print(main_arr) workbook.close()