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 cred = credentials.Certificate('servicekey.json') import firebase_admin from firebase_admin import credentials from firebase_admin import firestore try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') db = firestore.client() gt_fields_dir = 'Downloads/Halakindhi_Khasra.geojson' with open(gt_fields_dir) as f: gt_fields = json.load(f) farms_array = gt_fields["features"] for single_farm_obj in farms_array: geometry_obj = single_farm_obj["geometry"] points_obj = str(geometry_obj["coordinates"]) properties_obj = single_farm_obj["properties"] village = str(properties_obj["Village"]) village = village.lower() khasranum = str(properties_obj["Khasra_No"]) main_obj = { u'Points':points_obj, u'Village':village, u'ID':khasranum } # main_obj["Points"] = points_obj # main_obj["Village"] = village # main_obj["ID"] = khasranum #print(main_obj) v_id = round(time.time()*1000) v_id = str(v_id) print(main_obj) #db.collection(u'Villages_CI').document(v_id).set(main_obj) time.sleep(0.1) #break