Skip to main content

A Python package for interactive mapping using Google Earth Engine and ipyleaflet

Project description

geemap

https://colab.research.google.com/assets/colab-badge.svg https://mybinder.org/badge_logo.svg https://binder.pangeo.io/badge_logo.svg https://img.shields.io/pypi/v/geemap.svg https://pepy.tech/badge/geemap https://img.shields.io/travis/giswqs/geemap.svg https://readthedocs.org/projects/geemap/badge/?version=latest https://img.shields.io/badge/License-MIT-yellow.svg

Authors: Dr. Qiusheng Wu (https://wetlands.io)

A Python package for interactive mapping using Google Earth Engine, ipyleaflet, and ipywidgets.

Contents

Features

  • Automatically converts Earth Engine JavaScripts to Python scripts and Jupyter Notebooks.

  • Adds Earth Engine tile layers to ipyleaflet map for interactive mapping.

  • Supports Earth Engine JavaScript API functions in Python, such as Map.AddLayer(), Map.setCenter(), Map.centerObject(), Map.setOptions().

  • Captures user inputs and query Earth Engine objects.

  • Plots charts based on Earth Engine data.

Installation

To install geemap , run this command in your terminal:

pip install geemap

If you have Anaconda or Miniconda installed on your computer, you can use create conda Python environment to install geemap:

conda create -n gee python
conda activate gee
pip install geemap

If you have installed geemap before and want to upgrade to the latest version, you can use the following command:

pip install geemap -U

Examples

The following examples require the geemap package, which can be installed using pip install geemap. Check the Installation section for more information.

Converting GEE JavaScripts to Python scripts and Jupyter notebooks

Lanch an interactive notebook with Google Colab, mybinder.org, or binder.pangeo.io:

https://colab.research.google.com/assets/colab-badge.svg https://mybinder.org/badge_logo.svg https://binder.pangeo.io/badge_logo.svg
import os
from geemap.conversion import *

# Create a temporary working directory
work_dir = os.path.join(os.path.expanduser('~'), 'geemap')
# Get Earth Engine JavaScript examples. There are five examples in the geemap package folder.
# Change js_dir to your own folder containing your Earth Engine JavaScripts, such as js_dir = '/path/to/your/js/folder'
js_dir = get_js_examples(out_dir=work_dir)

# Convert all Earth Engine JavaScripts in a folder recursively to Python scripts.
js_to_python_dir(in_dir=js_dir, out_dir=js_dir, use_qgis=True)
print("Python scripts saved at: {}".format(js_dir))

# Convert all Earth Engine Python scripts in a folder recursively to Jupyter notebooks.
nb_template = get_nb_template()  # Get the notebook template from the package folder.
py_to_ipynb_dir(js_dir, nb_template)

# Execute all Jupyter notebooks in a folder recursively and save the output cells.
execute_notebook_dir(in_dir=js_dir)
https://i.imgur.com/8bedWtl.gif

Interactive mapping using GEE Python API and geemap

Lanch an interactive notebook with mybinder.org or binder.pangeo.io. Note that Google Colab currently does not support ipyleaflet. Therefore, geemap won’t be able to display interactive maps on Google Colab.

https://mybinder.org/badge_logo.svg https://binder.pangeo.io/badge_logo.svg
import ee
import geemap
import ipyleaflet

try:
        ee.Initialize()
except Exception as e:
        ee.Authenticate()
        ee.Initialize()

# Create an interactive map
Map = ipyleaflet.Map(center=(40, -100), zoom=4, scroll_wheel_zoom=True)
Map.setOptions('HYBRID') # Add Google Satellite basemap
Map

# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')

# Set visualization parameters.
vis_params = {
        'min': 0,
        'max': 4000,
        'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']
}

# Print the elevation of Mount Everest.
xy = ee.Geometry.Point([86.9250, 27.9881])
elev = image.sample(xy, 30).first().get('elevation').getInfo()
print('Mount Everest elevation (m):', elev)

# Add Earth Engine layers to Map
Map.addLayer(image, vis_params, 'STRM DEM', True, 0.5)
Map.addLayer(xy, {'color': 'red'}, 'Mount Everest')

# Set center of the map
Map.centerObject(ee_object=xy, zoom=13)
Map.setCenter(lon=-100, lat=40, zoom=4)
https://i.imgur.com/7NMQw6I.gif

Dependencies

Reporting Bugs

Report bugs at https://github.com/giswqs/geemap/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.

  • Any details about your local setup that might be helpful in troubleshooting.

  • Detailed steps to reproduce the bug.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-03-08)

  • First release on PyPI.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geemap-0.2.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

geemap-0.2.0-py2.py3-none-any.whl (27.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file geemap-0.2.0.tar.gz.

File metadata

  • Download URL: geemap-0.2.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for geemap-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f178f462137a2b8e787da146a532faf89d3f6ce16e17d14d47d42f2b0872cabf
MD5 1c0dbd9dc29c12d345b11996a01c3bce
BLAKE2b-256 4aef477d869a161145140d7a3c033b3329603c13b646a60a8782ca0a2402013b

See more details on using hashes here.

File details

Details for the file geemap-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: geemap-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

File hashes

Hashes for geemap-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c4b47ff0a1fea6ddcd9c7d0a424e7625dea41493eeabe770286cde403c89eae2
MD5 64facd2c1462decf554598e4faff8fb6
BLAKE2b-256 ee79273f7e7cf25717592176266de709dd1c3d1f969452ac2f5895382bf8edf7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page