1

If I use python api for google earth engine and want to make a UI chart for mean value of NDVI for a particular year , how does the UI.CHART function work in python api for google earth engine.

4

There is a library in the universe of Jake Vanderplas that I have used to make charts in Google Earth Engine: pygal. May not be the best or newest, but it works. I have incorporated the method in a python package called geetools. You can install it via pip.

At the moment, the only method available is series (to plot a time series), but I am about to incorporate seriesByRegion, because I need them for work, the rest will have to wait.

There is a notebook in which I show how to use it: chart.ipynb, and the equivalent code in JS (https://code.earthengine.google.com/e50afcbdc75fbb9611a4ac7d6567fdf8)

I leave the code here as well:

# coding: utf-8
# # chart module

import ee    
from geetools import chart

test_site = ee.Geometry.Point([-71, -42])

# ## Time Series
years = ee.List([2015, 2016, 2017, 2018])

col = ee.ImageCollection('COPERNICUS/S2').filterBounds(test_site)

def make_time_series(year):
    ''' make a time series from year's list '''
    eefilter = ee.Filter.calendarRange(year, field='year')
    filtered = col.filter(eefilter)
    return filtered.mean().set('system:time_start', ee.Date.fromYMD(year, 1, 1).millis())

time_series = ee.ImageCollection(years.map(make_time_series))

# ## Chart *series*
chart_ts = chart.Image.series(**{
    'imageCollection': time_series, 
    'region': test_site,
    'scale': 10,
    'bands': ['B1', 'B2', 'B3']
})

# chart_ts.render_widget()  # for Jupyter Notebook or Lab
chart_ts.render_in_browser()  # for Spyder

As the resulting chart chart_ts is a subclass of a pygal chart, you can use all its methods, like render_to_file, etc, and all its attributes.

3

The ui.Chart class is only available in the Earth Engine Code Editor application. It is not part of the JavaScript or Python API libraries.

Using the Earth Engine Python API, you can pull data into a Python data structure (such as a Pandas dataframe) and use a wide variety of Python visualization libraries to view the data. For a good overview of popular libraries, see Jake Vanderplas' talk The Python Visualization Landscape from PyCon 2017.

  • Thank you Tyler for the suggestion. I am presently working with real time analysis using Earth Engine and it would be great to stay in touch – Sohini Goswami Aug 7 '18 at 6:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.