I have found some sample code that returns features from a GEE image to a pandas dataframe based on specific points in my feature collection.
The challenge is I need the geometry on these points to be returned next to the features in the dataframe so that I can spatially join it to another dataset.
Please advise as to how this can be done.
import ee
import pandas as pd
ee.Initialize()
districts = points_features_collections
# selecting images with a data/time stamp and averaging results
chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").select('precipitation').filterDate('2018-01-01', '2018-12-31').mean()
evi = ee.ImageCollection('MODIS/006/MOD13A2').select('EVI').filterDate('2018-01-01', '2018-12-31').mean()
composite = ee.Image.cat([chirps, evi]) #concat multiple images into one
# stores multiple regions as one in a feature collection
dist_stats = composite.reduceRegions(districts, 'mean', 5000)
dist_stats = dist_stats.select(['precipitation', 'EVI'], ['tot_rainfall', 'med_evi'], retainGeometry=False).getInfo()
dtstats_df = pd.DataFrame()
for dist in dist_stats['features']:
df = pd.DataFrame([dist['properties']],columns=dist['properties'].keys())
dtstats_df = pd.concat([dtstats_df, df], sort=True, axis=0)
dtstats_df = dtstats_df[['tot_rainfall', 'med_evi']]
dtstats_df
Results:
tot_rainfall med_evi
0 1.233124 2018.826087
0 1.175122 1761.086957
0 1.233124 2018.826087