Let's see how to convert non-Earth Engine classes to Earth Engine classes.
Before anything, let's import our modules and authenticate in Google Earth Engine:
import ee, eemont
import pandas as pd
ee.Authenticate()
ee.Initialize()
Now, we are ready to go!
The eemont package extends the pd.DataFrame classes with the method toEEFeatureCollection()
:
pd.DataFrame ~~~~~~~~
eemont.dataframe
toEEFeatureCollection
A table of availabe conversion options is shown below:
Available optionsFrom | To | Method |
---|---|---|
pd.DataFrame | ee.FeatureCollection | toEEFeatureCollection() |
Let's create a pandas data frame:
df = pd.DataFrame()
df['lat'] = [2.92846, 4.8927]
df['lon'] = [-76.0269, -75.3188]
df['name'] = ['Nevado del Huila', 'Nevado del Ruiz']
This data frame can be easily converted into a ee.FeatureCollection (with no geometries) using the toEEFeatureCollection()
method for pd.DataFrame classes:
fcWithNoGeometries = df.toEEFeatureCollection()
If the data frame has latitude and longitude columns, these can be specified in the latitude
and longitude
parameters:
fcWithGeometries = df.toEEFeatureCollection(latitude = 'lat',longitude = 'lon')