Nothing Special   »   [go: up one dir, main page]

Skip to content

Interactive Code Editor-style reprs for Earth Engine objects in a Jupyter notebook

License

Notifications You must be signed in to change notification settings

aazuspan/eerepr

Repository files navigation

eerepr

Earth Engine Python PyPI version conda-forge link nbviewer Binder Open In Colab

Add interactive Code Editor-style HTML reprs to Earth Engine objects in a Jupyter environment.

eerepr demo expanding the metadata for an image collection

Setup

Tip

eerepr is pre-installed in Google Colab!

Install from PyPI:

$ pip install eerepr

Install from Conda-Forge:

$ conda install -c conda-forge eerepr

Usage

Activating eerepr

import eerepr

Importing eerepr in a Jupyter notebook adds an HTML repr method to all Earth Engine objects. When you print them, you'll see an interactive HTML repr instead of a boring old string repr. Simple as that!

Tip

If you're using geemap, eerepr is automatically imported and activated by default!

Manually Rendering Objects

Jupyter only automatically displays the last object in a cell. To manually render an HTML repr anywhere in a code block, use IPython.display.display.

from IPython.display import display
import ee
import eerepr

ee.Initialize()

display(ee.FeatureCollection("LARSE/GEDI/GEDI02_A_002_INDEX").limit(3))

Large Objects

Caution

Just like in the Code Editor, printing huge collections can be slow and may hit memory limits. If a repr exceeds 100 Mb, eerepr will fallback to a string repr to avoid freezing the notebook. Adjust eerepr.options.max_repr_mbs to print larger objects.

Caching

eerepr uses caching to improve performance. Server data will only be requested once for each unique Earth Engine object, and all subsequent requests will be retrieved from the cache until the Jupyter session is restarted.

When you import eerepr, it is automatically initialized with an unlimited cache size. You can manually set the number of unique objects to cache using eerepr.initialize(max_cache_size=n). A value of None sets an unlimited cache while a value of 0 disables caching.