Integrate Google Earth Engine(GEE), Pandas framework and Matplotlip - Spatial Data Mining

Published on Apr 04, 2020 | Bikesh Bade | 1178 Views

Google Earth Engine is designed for cloud-based, parallelized geospatial data analysis. GEE takes care of all the infrastructure and parallelization decisions on the back end for you. The GEE catalog hosts multiple petabytes of satellite imagery in the cloud, including the entire Landsat mission. Other remote sensing missions represented include Sentinel 1, Sentinel 2, MODIS and others. In addition to earth observing images, GEE also hosts produced datasets for precipitation, population density, topography, land cover and climate. Over 6000 scenes are added daily from active satellite missions. 


The JavaScript GUI in GEE is a fully built web platform that you make requests through to the main GEE API. But there is a way to bring the power of GEE to your Jupyter notebook and automate the system, extract useful data from petabytes of data, discover the pattern in data, visualize in multiple Matplotlib charts, analyze the data with powerful Pandas and bring data to knowledge. 


Set up Python API for GEE and continue following 


The Python API provides a programmatic and flexible interface to Earth Engine. It allows for automating batch processing tasks, piping Earth Engine processed data to Python packages for post-processing and leveraging the power of the command line.


The Python API package is called ee. It must also be initialized for every new session and script.


# import Google earth engine module
import ee

#Authenticate the Google earth engine with google account


To use GEE Tools in python API, there is a python library called ipygee which helps bring tools to your Jupyter notebook. Install ipygee as PIP


pip install ipygee 


Now import ipygee and use the GEE tool to discover the pattern in petabytes of the satellite images.


#import module 
from ipygee import *

#Define year
startyear = 2019;
endyear = 2019;

#Create the Date object
startdate = ee.Date.fromYMD(startyear,6,1);
enddate = ee.Date.fromYMD(endyear,11,1);

#assign the modis image for the NDVI
dataset = ee.ImageCollection('MODIS/006/MOD13Q1').filterDate(startdate,enddate );
modisndvi ='NDVI');
modisevi ='EVI');

#Generate the GEE tool and get the data as seriesByRegion
chart_ts_region = chart.Image.seriesByRegion(**{
    'imageCollection': modisndvi,
    'reducer': ee.Reducer.median(),
    'regions': riceland,
    'band': 'NDVI',
    'seriesProperty': 'sn'

#convert Image data to pandas framework 
df =chart_ts_region.dataframe

In the above code, Modis NDVI pixel value is generated for the year 2019 and converted into pandas framework. Now you can perform any pandas data manipulation and analysis on the data.


#display the data in table 

#get the shape of the data

#Index or slice the data as per need

Next plot the data in the chart and discover the pattern in the data. Visualize the data in different charts


#import matplotlib
%matplotlib inline

#plot the data in desired chart

So bring the giant in data mining in single table and discover the unseen pattern.


Rodrigo E. Principe

Thank you for using ipygee =) You as a final user, could you compare ipygee's Map vs geemap's Map? That would be a good post ;)

  • Apr 11, 2020 |


dear i wrote this code but this not work properly, because it shows region riceland not define in ee environment and also df head, df shape also not define error comes pl guide me relevant code thank you

  • Apr 12, 2020 |

Leave your comment