0

I am trying to get a pandas or geopandas dataframe returned from a Google Earth Engine FeatureCollection for specific point data. Basically like a spatial intersect where all values from the feature collection are returned for each point.

I found this code example below but it returns with a warning that the nonconcat axis is not aligned. My end goal is to perform Machine Learning so I need to make sure that the point data is perfectly aligned with the results returned.

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', 7000)

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], axis=0)

dtstats_df = dtstats_df[['tot_rainfall', 'med_evi']]

dtstats_df

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.