Data Conversion

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!

Overview

The eemont package extends the pd.DataFrame classes with the method toEEFeatureCollection():

pd.DataFrame

toEEFeatureCollection(self[, latitude, …])

Converts a pd.DataFrame object into an ee.FeatureCollection object.

Methods

A table of availabe conversion options is shown below:

Available options

From

To

Method

pd.DataFrame

ee.FeatureCollection

toEEFeatureCollection()

Usage

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