import numpy as np import os,sys import cv2 import csv import firebase_admin from firebase_admin import credentials from firebase_admin import db from firebase_admin import messaging import time import threading import os from numba import jit, cuda cred = credentials.Certificate('servicekey.json') try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/','storageBucket': 'farmbase-b2f7e.appspot.com'}) except: print('fire running') uids = ['u5ZgAskSltX7dQdNFUlHsgVhAlf2','b2j92LjidjeGt2b60QHhSj4GeS63','0AC0f8JWjUdg9fCm7f8QbXZTOp23'] area = 0 num = 0 all_points_arr = [] for uid in uids: uid_obj = db.reference('PaidMonitoredFields').child('PMF').child(uid).get() for (fieldid, fieldobj) in uid_obj.items(): area = area + int(fieldobj["FieldArea"]) num = num + 1 single_field_points = [] pointsObj = fieldobj["Coordinates"] midlat,midlng = 0,0 pointnum = 0 for (point_key, singlePoint) in pointsObj.items(): midlat= midlat + singlePoint["Latitude"] midlng = midlng + singlePoint["Longitude"] pointnum = pointnum + 1 midlat = midlat/pointnum midlng = midlng/pointnum all_points_arr.append([midlat,midlng]) np.savetxt("all_points_obj.csv", all_points_arr, delimiter = ",") print(float(area/10000)) print(num)