Geemap Readthedocs Io en Latest
Geemap Readthedocs Io en Latest
Release 0.16.3
Qiusheng Wu
1 geemap 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7 Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.8 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.9 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Installation 15
2.1 Stable release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 From sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3 Usage 17
4 Modules 19
4.1 geemap package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5 Contributing 77
5.1 Types of Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.2 Get Started! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.3 Pull Request Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.4 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.5 Deploying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6 Credits 81
6.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7 History 83
7.1 0.7.0 (2020-05-22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.2 0.6.0 (2020-04-05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.3 0.5.0 (2020-03-24) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.4 0.4.0 (2020-03-19) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.5 0.3.0 (2020-03-18) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
i
7.6 0.2.0 (2020-03-17) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.7 0.1.0 (2020-03-08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Index 87
ii
CHAPTER 1
geemap
A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and ipywidgets.
• GitHub repo: https://github.com/giswqs/geemap
• Documentation: https://geemap.org
• PyPI: https://pypi.org/project/geemap/
• Conda-forge: https://anaconda.org/conda-forge/geemap
• 360+ GEE notebook examples: https://github.com/giswqs/earthengine-py-notebooks
• GEE Tutorials on YouTube: https://www.youtube.com/c/QiushengWu
• Free software: MIT license
Contents
1
geemap Documentation, Release 0.16.3
• Introduction
• Features
• Installation
• Usage
• Examples
• Dependencies
• Contributing
• References
• Credits
1.1 Introduction
geemap is a Python package for interactive mapping with Google Earth Engine (GEE), which is a cloud computing
platform with a multi-petabyte catalog of satellite imagery and geospatial datasets. During the past few years, GEE
has become very popular in the geospatial community and it has empowered numerous environmental applications
at local, regional, and global scales. GEE provides both JavaScript and Python APIs for making computational re-
quests to the Earth Engine servers. Compared with the comprehensive documentation and interactive IDE (i.e., GEE
JavaScript Code Editor) of the GEE JavaScript API, the GEE Python API has relatively little documentation and lim-
ited functionality for visualizing results interactively. The geemap Python package was created to fill this gap. It is
built upon ipyleaflet and ipywidgets, and enables users to analyze and visualize Earth Engine datasets interactively
within a Jupyter-based environment.
geemap is intended for students and researchers, who would like to utilize the Python ecosystem of diverse libraries
and tools to explore Google Earth Engine. It is also designed for existing GEE users who would like to transition from
the GEE JavaScript API to Python API. The automated JavaScript-to-Python conversion module of the geemap pack-
age can greatly reduce the time needed to convert existing GEE JavaScripts to Python scripts and Jupyter notebooks.
For video tutorials and notebook examples, please visit https://geemap.org/tutorials. For complete documentation on
geemap modules and methods, please visit https://geemap.org/geemap.
If you find geemap useful in your research, please consider citing the following papers to support my work. Thank
you for your support.
• Wu, Q., (2020). geemap: A Python package for interactive mapping with Google Earth Engine. The Journal of
Open Source Software, 5(51), 2305. https://doi.org/10.21105/joss.02305
• Wu, Q., Lane, C. R., Li, X., Zhao, K., Zhou, Y., Clinton, N., DeVries, B., Golden, H. E., & Lang, M. W.
(2019). Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using
Google Earth Engine. Remote Sensing of Environment, 228, 1-13. https://doi.org/10.1016/j.rse.2019.04.015
(pdf | source code)
Check out the geemap workshop I presented at the GeoPython Conference 2021. This workshop gives a comprehensive
introduction to the key features of geemap.
2 Chapter 1. geemap
geemap Documentation, Release 0.16.3
1.2 Features
Below is a partial list of features available for the geemap package. Please check the examples page for notebook
examples, GIF animations, and video tutorials.
• Convert Earth Engine JavaScripts to Python scripts and Jupyter notebooks.
• Display Earth Engine data layers for interactive mapping.
• Support Earth Engine JavaScript API-styled functions in Python, such as Map.addLayer(), Map.setCenter(),
Map.centerObject(), Map.setOptions().
• Create split-panel maps with Earth Engine data.
• Retrieve Earth Engine data interactively using the Inspector Tool.
• Interactive plotting of Earth Engine data by simply clicking on the map.
• Convert data format between GeoJSON and Earth Engine.
• Use drawing tools to interact with Earth Engine data.
• Use shapefiles with Earth Engine without having to upload data to one’s GEE account.
• Export Earth Engine FeatureCollection to other formats (i.e., shp, csv, json, kml, kmz).
• Export Earth Engine Image and ImageCollection as GeoTIFF.
1.2. Features 3
geemap Documentation, Release 0.16.3
1.3 Installation
To use geemap, you must first sign up for a Google Earth Engine account.
geemap is available on PyPI. To install geemap, run this command in your terminal:
geemap is also available on conda-forge. If you have Anaconda or Miniconda installed on your computer, you can
create a conda Python environment to install geemap:
Optionally, you can install Jupyter notebook extensions, which can improve your productivity in the notebook envi-
ronment. Some useful extensions include Table of Contents, Gist-it, Autopep8, Variable Inspector, etc. See this post
for more information.
If you have installed geemap before and want to upgrade to the latest version, you can run the following command in
your terminal:
4 Chapter 1. geemap
geemap Documentation, Release 0.16.3
If you use conda, you can update geemap to the latest version by running the following command in your terminal:
To install the development version from GitHub using Git, run the following command in your terminal:
To install the development version from GitHub directly within Jupyter notebook without using Git, run the following
code:
import geemap
geemap.update_package()
To use geemap in a Docker container, check out the following docker containers with geemap installed.
• gee-community/ee-jupyter-contrib
• bkavlak/geemap
• giswqs/geemap
To use geemap in a Docker container, check out ee-jupyter-contrib or this page.
1.4 Usage
Important note: A key difference between ipyleaflet and folium is that ipyleaflet is built upon ipywidgets and allows
bidirectional communication between the front-end and the backend enabling the use of the map to capture user input,
while folium is meant for displaying static data only (source). Note that Google Colab currently does not support
ipyleaflet (source). Therefore, if you are using geemap with Google Colab, you should use import geemap.foliumap.
If you are using geemap with binder or a local Jupyter notebook server, you can use import geemap, which provides
more functionalities for capturing user input (e.g., mouse-clicking and moving).
More GEE Tutorials are available on my YouTube channel.
1.4. Usage 5
geemap Documentation, Release 0.16.3
import geemap
Map = geemap.Map(center=[40,-100], zoom=4)
Map
To center the map view at a given coordinates with the given zoom level:
Map.centerObject(ee_object, zoom)
Map.addLayerControl()
6 Chapter 1. geemap
geemap Documentation, Release 0.16.3
Map.add_minimap()
Map.add_basemap('Esri Ocean')
Map.add_basemap('Esri National Geographic')
url = 'https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}'
Map.add_tile_layer(url, name='Google Map', attribution='Google')
naip_url = 'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/
˓→ImageServer/WMSServer?'
ee_object = geemap.shp_to_ee(shp_file_path)
Map.addLayer(ee_object, {}, 'Layer name')
To convert a GeoJSON file to Earth Engine object and add it to the Map:
ee_object = geemap.geojson_to_ee(geojson_file_path)
Map.addLayer(ee_object, {}, 'Layer name')
To export an ee.FeatureCollection to other formats, including shp, csv, json, kml, and kmz:
To import a 2D or 3D numpy array to an ee.Image using a given base coordinate reference system (crs) and transform
between projected coordinates and the base:
To import one or more variables from a netCDF file with a regular grid in EPSG:4326 to an ee.Image:
1.4. Usage 7
geemap Documentation, Release 0.16.3
Map.split_map(left_layer='HYBRID', right_layer='ESRI')
Map.marker_cluster()
feature_collection = ee.FeatureCollection(Map.ee_markers)
legend_dict = {
'one': (0, 0, 0),
'two': (255,255,0),
'three': (127, 0, 127)
}
Map.add_legend(legend_title='Legend', legend_dict=legend_dict, position='bottomright')
Map.add_legend(builtin_legend='NLCD')
8 Chapter 1. geemap
geemap Documentation, Release 0.16.3
To execute all Jupyter notebooks in a folder recursively and save output cells:
import geemap
geemap.ee_search()
geemap.image_props(image).getInfo()
geemap.remove_drawn_features()
geemap.extract_values_to_points(out_shp)
image = geemap.load_GeoTIFF(URL)
collection = geemap.load_GeoTIFFs(URLs)
1.5 Examples
The following examples require the geemap package, which can be installed using pip install geemap. Check
the Installation section for more information. More examples can be found at another repo: A collection of 300+
Jupyter Python notebook examples for using Google Earth Engine with interactive mapping.
• Converting GEE JavaScripts to Python scripts and Jupyter notebooks
• Interactive mapping using GEE Python API and geemap
1.5. Examples 9
geemap Documentation, Release 0.16.3
Launch an interactive notebook with Google Colab. Keep in mind that the conversion might not always work per-
fectly. Additional manual changes might still be needed. ui and chart are not supported. The source code for this
automated conversion module can be found at conversion.py.
import os
from geemap.conversion import *
# 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)
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)
Launch an interactive notebook with Google Colab. Note that Google Colab currently does not support ipyleaflet.
Therefore, you should use import geemap.foliumap instead of import geemap.
try:
import geemap
except ImportError:
print('geemap package not installed. Installing ...')
subprocess.check_call(["python", '-m', 'pip', 'install', 'geemap'])
10 Chapter 1. geemap
geemap Documentation, Release 0.16.3
try:
ee.Initialize()
except Exception as e:
ee.Authenticate()
ee.Initialize()
1.6 Dependencies
• bqplot
• colour
• earthengine-api
• folium
• geeadd
• geocoder
• ipyfilechooser
• ipyleaflet
• ipynb-py-convert
• ipytree
1.6. Dependencies 11
geemap Documentation, Release 0.16.3
• ipywidgets
• mss
• pillow
• pyshp
• xarray-leaflet
1.7 Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants
to implement it.
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to
whoever wants to implement it.
geemap could always use more documentation, whether as part of the official geemap docs, in docstrings, or even on
the web in blog posts, articles, and such.
12 Chapter 1. geemap
geemap Documentation, Release 0.16.3
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development:
$ mkvirtualenv geemap
$ cd geemap/
$ python setup.py develop
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub:
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function
with a docstring, and add the feature to the list in README.rst.
3. The pull request should work for Python 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.com/giswqs/
geemap/pull_requests and make sure that the tests pass for all supported Python versions.
1.7.8 Tips
1.7. Contributing 13
geemap Documentation, Release 0.16.3
1.7.9 Deploying
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in
HISTORY.rst). Then run:
1.8 References
1.9 Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
14 Chapter 1. geemap
CHAPTER 2
Installation
This is the preferred method to install geemap, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
The sources for geemap can be downloaded from the Github repo.
You can either clone the public repository:
Once you have a copy of the source, you can install it with:
15
geemap Documentation, Release 0.16.3
16 Chapter 2. Installation
CHAPTER 3
Usage
import geemap
17
geemap Documentation, Release 0.16.3
18 Chapter 3. Usage
CHAPTER 4
Modules
4.1.1 Submodules
Module for basemaps. Each basemap is defined as item in the basemaps dictionary. For example, to access Google
basemaps, use the following:
basemaps[‘ROADMAP’], basemaps[‘SATELLITE’], basemaps[‘HYBRID’].
More WMS basemaps can be found at the following websites:
1. USGS National Map: https://viewer.nationalmap.gov/services/
2. MRLC NLCD Land Cover data: https://viewer.nationalmap.gov/services/
3. FWS NWI Wetlands data: https://www.fws.gov/wetlands/Data/Web-Map-Services.html
geemap.basemaps.get_qms(service_id)
geemap.basemaps.get_xyz_dict(free_only=True, _collection=None, _output=None)
Returns a dictionary of xyz services.
Parameters free_only (bool, optional) – Whether to return only free xyz tile services that
do not require an access token. Defaults to True.
Returns A dictionary of xyz services.
Return type dict
geemap.basemaps.qms_to_geemap(service_id)
geemap.basemaps.search_qms(keywords, limit=10)
Search qms files for keywords. Reference: https://github.com/geopandas/xyzservices/issues/65
Parameters
19
geemap Documentation, Release 0.16.3
Module for converting Google Earth Engine (GEE) JavaScripts to Python scripts and Jupyter notebooks.
To convert a GEE JavaScript to Python script: js_to_python(in_file out_file)
To convert all GEE JavaScripts in a folder recursively to Python scripts: js_to_python_dir(in_dir, out_dir)
To convert a GEE Python script to Jupyter notebook: py_to_ipynb(in_file, template_file, out_file)
To convert all GEE Python scripts in a folder recursively to Jupyter notebooks: py_to_ipynb_dir(in_dir, template_file,
out_dir)
To execute a Jupyter notebook and save output cells: execute_notebook(in_file)
To execute all Jupyter notebooks in a folder recursively: execute_notebook_dir(in_dir)
geemap.conversion.check_map_functions(input_lines)
Extracts Earth Engine map function
Parameters input_lines (list) – List of Earth Engine JavaScrips
20 Chapter 4. Modules
geemap Documentation, Release 0.16.3
22 Chapter 4. Modules
geemap Documentation, Release 0.16.3
Args: in_dir (str): The input folder containing Earth Engine JavaScripts. out_dir (str, optional):
The output folder containing Earth Engine Python scripts. Defaults to None. use_qgis (bool,
optional): Whether to add “from ee_plugin import Map
” to the output script. Defaults to True. github_repo (str, optional): GitHub repo url. Defaults to None.
Parameters
• in_file (str) – The input Jupyter notebook.
• github_username (str, optional) – GitHub username. Defaults to None.
• github_repo (str, optional) – GitHub repo name. Defaults to None.
geemap.conversion.update_nb_header_dir(in_dir, github_username=None,
github_repo=None)
Updates header (binder and Google Colab URLs) of all notebooks in a folder .
Parameters
• in_dir (str) – The input directory containing Jupyter notebooks.
• github_username (str, optional) – GitHub username. Defaults to None.
• github_repo (str, optional) – GitHub repo name. Defaults to None.
geemap.conversion.use_math(lines)
Checks if an Earth Engine uses Math library
Parameters lines (list) – An Earth Engine JavaScript.
Returns Returns True if the script contains ‘Math.’. For example ‘Math.PI’, ‘Math.pow’
Return type [bool]
This module extends the folium Map class. It is designed to be used in Google Colab, as Google Colab currently does
not support ipyleaflet.
class geemap.foliumap.Map(**kwargs)
Bases: folium.folium.Map
The Map class inherits from folium.Map. By default, the Map will add Google Maps as the basemap. Set
add_google_map = False to use OpenStreetMap as the basemap.
Returns folium map object.
Return type object
addLayer(ee_object, vis_params={}, name=’Layer untitled’, shown=True, opacity=1.0, **kwargs)
Adds a given EE object to the map as a layer.
Parameters
• ee_object (Collection|Feature|Image|MapId) – The object to add to the
map.
• vis_params (dict, optional) – The visualization parameters. Defaults to {}.
• name (str, optional) – The name of the layer. Defaults to ‘Layer untitled’.
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• opacity (float, optional) – The layer’s opacity represented as a number between
0 and 1. Defaults to 1.
addLayerControl()
Adds layer control to the map.
24 Chapter 4. Modules
geemap Documentation, Release 0.16.3
add_basemap(basemap=’HYBRID’)
Adds a basemap to the map.
Parameters basemap (str, optional) – Can be one of string from ee_basemaps. De-
faults to ‘HYBRID’.
add_census_data(wms, layer, census_dict=None, **kwargs)
Adds a census data layer to the map.
Parameters
• wms (str) – The wms to use. For example, “Current”, “ACS 2021”, “Census 2020”. See
the complete list at https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_wms.html
• layer (str) – The layer name to add to the map.
• census_dict (dict, optional) – A dictionary containing census data. Defaults
to None. It can be obtained from the get_census_dict() function.
add_circle_markers_from_xy(data, x=’longitude’, y=’latitude’, radius=10, popup=None,
tooltip=None, min_width=100, max_width=200, **kwargs)
Adds a marker cluster to the map.
Parameters
• data (str | pd.DataFrame) – A csv or Pandas DataFrame containing x, y, z values.
• x (str, optional) – The column name for the x values. Defaults to “longitude”.
• y (str, optional) – The column name for the y values. Defaults to “latitude”.
• radius (int, optional) – The radius of the circle. Defaults to 10.
• popup (list, optional) – A list of column names to be used as the popup. Defaults
to None.
• tooltip (list, optional) – A list of column names to be used as the tooltip. De-
faults to None.
• min_width (int, optional) – The minimum width of the popup. Defaults to 100.
• max_width (int, optional) – The maximum width of the popup. Defaults to 200.
add_cog_layer(url, name=’Untitled’, attribution=’.’, opacity=1.0, shown=True, bands=None,
titiler_endpoint=’https://titiler.xyz’, **kwargs)
Adds a COG TileLayer to the map.
Parameters
• url (str) – The URL of the COG tile layer.
• name (str, optional) – The layer name to use for the layer. Defaults to ‘Untitled’.
• attribution (str, optional) – The attribution to use. Defaults to ‘.’.
• opacity (float, optional) – The opacity of the layer. Defaults to 1.
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• bands (list, optional) – A list of bands to use. Defaults to None.
• titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://
titiler.xyz”.
add_cog_mosaic(**kwargs)
26 Chapter 4. Modules
geemap Documentation, Release 0.16.3
labels [list-like] A list of legend labels to override the auto-generated labblels. Needs to
have the same number of elements as the number of classes (k).
interval [boolean (default False)] An option to control brackets from mapclassify legend.
If True, open/closed interval brackets are shown in the legend.
28 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• opacity (float, optional) – The layer’s opacity represented as a number between
0 and 1. Defaults to 1.
add_layer_control()
Adds layer control to the map.
add_legend(title=’Legend’, colors=None, labels=None, legend_dict=None, builtin_legend=None,
opacity=1.0, **kwargs)
Adds a customized legend to the map. Reference: https://bit.ly/3oV6vnH
Parameters
• title (str, optional) – Title of the legend. Defaults to ‘Legend’. Defaults to
“Legend”.
• colors (list, optional) – A list of legend colors. Defaults to None.
• labels (list, optional) – A list of legend labels. Defaults to None.
• legend_dict (dict, optional) – A dictionary containing legend items as keys
and color as values. If provided, legend_keys and legend_colors will be ignored. Defaults
to None.
• builtin_legend (str, optional) – Name of the builtin legend to add to the map.
Defaults to None.
• opacity (float, optional) – The opacity of the legend. Defaults to 1.0.
add_marker(location, popup=None, tooltip=None, icon=None, draggable=False, **kwargs)
Adds a marker to the map. More info about marker options at https://python-visualization.github.io/folium/
modules.html#folium.map.Marker.
Parameters
• location (list | tuple) – The location of the marker in the format of [lat, lng].
• popup (str, optional) – The popup text. Defaults to None.
• tooltip (str, optional) – The tooltip text. Defaults to None.
• icon (str, optional) – The icon to use. Defaults to None.
• draggable (bool, optional) – Whether the marker is draggable. Defaults to False.
add_netcdf(filename, variables=None, palette=None, vmin=None, vmax=None, nodata=None, at-
tribution=None, layer_name=’NetCDF layer’, shift_lon=True, lat=’lat’, lon=’lon’,
**kwargs)
Generate an ipyleaflet/folium TileLayer from a netCDF file. If you are using this function in Jupyter-
Hub on a remote server (e.g., Binder, Microsoft Planetary Computer), try adding to following two
lines to the beginning of the notebook if the raster does not render properly.
import os os.environ[‘LOCALTILESERVER_CLIENT_PREFIX’] =
f’{os.environ[‘JUPYTERHUB_SERVICE_PREFIX’].lstrip(‘/’)}/proxy/{{port}}’
Parameters
• filename (str) – File path or HTTP URL to the netCDF file.
• variables (int, optional) – The variable/band names to extract data from the
netCDF file. Defaults to None. If None, all variables will be extracted.
• port (str, optional) – The port to use for the server. Defaults to “default”.
30 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to “netCDF layer”.
• shift_lon (bool, optional) – Flag to shift longitude values from [0, 360] to the
range [-180, 180]. Defaults to True.
• lat (str, optional) – Name of the latitude variable. Defaults to ‘lat’.
• lon (str, optional) – Name of the longitude variable. Defaults to ‘lon’.
• tags (dict) – Dict of tags used for finding objects in the selected area. Results returned
are the union, not intersection of each individual tag. Each result matches at least one
given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and
the dict values should be either True to retrieve all items with the given tag, or a string
to get a single tag-value combination, or a list of strings to get multiple values for the
given tag. For example, tags = {‘building’: True} would return all building footprints in
the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’}
would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop.
• dist (int, optional) – Distance in meters. Defaults to 1000.
• layer_name (str, optional) – The layer name to be used.. Defaults to “Untitled”.
• style (dict, optional) – A dictionary specifying the style to be used. Defaults to
{}.
• hover_style (dict, optional) – Hover style dictionary. Defaults to {}.
• style_callback (function, optional) – Styling function that is called for
each feature, and should return the feature style. This styling function takes the feature
as argument. Defaults to None.
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
add_osm_from_bbox(north, south, east, west, tags, layer_name=’Untitled’, style={},
hover_style={}, style_callback=None, fill_colors=[’black’],
info_mode=’on_hover’)
Adds OSM entities within a N, S, E, W bounding box to the map.
Parameters
• north (float) – Northern latitude of bounding box.
• south (float) – Southern latitude of bounding box.
• east (float) – Eastern longitude of bounding box.
• west (float) – Western longitude of bounding box.
• tags (dict) – Dict of tags used for finding objects in the selected area. Results returned
are the union, not intersection of each individual tag. Each result matches at least one
given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and
the dict values should be either True to retrieve all items with the given tag, or a string
to get a single tag-value combination, or a list of strings to get multiple values for the
given tag. For example, tags = {‘building’: True} would return all building footprints in
the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’}
would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop.
• layer_name (str, optional) – The layer name to be used.. Defaults to “Untitled”.
• style (dict, optional) – A dictionary specifying the style to be used. Defaults to
{}.
• hover_style (dict, optional) – Hover style dictionary. Defaults to {}.
• style_callback (function, optional) – Styling function that is called for
each feature, and should return the feature style. This styling function takes the feature
as argument. Defaults to None.
32 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
add_osm_from_geocode(query, which_result=None, by_osmid=False, buffer_dist=None,
layer_name=’Untitled’, style={}, hover_style={}, style_callback=None,
fill_colors=[’black’], info_mode=’on_hover’)
Adds OSM data of place(s) by name or ID to the map.
Parameters
• query (str | dict | list) – Query string(s) or structured dict(s) to geocode.
• which_result (int, optional) – Which geocoding result to use. if None, auto-
select the first (Multi)Polygon or raise an error if OSM doesn’t return one. to get the top
match regardless of geometry type, set which_result=1. Defaults to None.
• by_osmid (bool, optional) – If True, handle query as an OSM ID for lookup
rather than text search. Defaults to False.
• buffer_dist (float, optional) – Distance to buffer around the place geometry,
in meters. Defaults to None.
• layer_name (str, optional) – The layer name to be used.. Defaults to “Untitled”.
• style (dict, optional) – A dictionary specifying the style to be used. Defaults to
{}.
• hover_style (dict, optional) – Hover style dictionary. Defaults to {}.
• style_callback (function, optional) – Styling function that is called for
each feature, and should return the feature style. This styling function takes the feature
as argument. Defaults to None.
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
add_osm_from_place(query, tags, which_result=None, buffer_dist=None, layer_name=’Untitled’,
style={}, hover_style={}, style_callback=None, fill_colors=[’black’],
info_mode=’on_hover’)
Adds OSM entities within boundaries of geocodable place(s) to the map.
Parameters
• query (str | dict | list) – Query string(s) or structured dict(s) to geocode.
• tags (dict) – Dict of tags used for finding objects in the selected area. Results returned
are the union, not intersection of each individual tag. Each result matches at least one
given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and
the dict values should be either True to retrieve all items with the given tag, or a string
to get a single tag-value combination, or a list of strings to get multiple values for the
given tag. For example, tags = {‘building’: True} would return all building footprints in
the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’}
would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop.
34 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• year (int, optional) – The year of Planet global mosaic, must be >=2016. Defaults
to 2016.
• quarter (int, optional) – The quarter of Planet global mosaic, must be 1-12.
Defaults to 1.
• name (str, optional) – The layer name to use. Defaults to None.
• api_key (str, optional) – The Planet API key. Defaults to None.
• token_name (str, optional) – The environment variable name of the API key.
Defaults to “PLANET_API_KEY”.
add_points_from_xy(data, x=’longitude’, y=’latitude’, popup=None, min_width=100,
max_width=200, layer_name=’Marker Cluster’, color_column=None,
marker_colors=None, icon_colors=[’white’], icon_names=[’info’], an-
gle=0, prefix=’fa’, add_legend=True, **kwargs)
Adds a marker cluster to the map.
Parameters
• data (str | pd.DataFrame) – A csv or Pandas DataFrame containing x, y, z values.
• x (str, optional) – The column name for the x values. Defaults to “longitude”.
• y (str, optional) – The column name for the y values. Defaults to “latitude”.
• popup (list, optional) – A list of column names to be used as the popup. Defaults
to None.
• min_width (int, optional) – The minimum width of the popup. Defaults to 100.
• max_width (int, optional) – The maximum width of the popup. Defaults to 200.
• layer_name (str, optional) – The name of the layer. Defaults to “Marker Clus-
ter”.
• color_column (str, optional) – The column name for the color values. Defaults
to None.
• marker_colors (list, optional) – A list of colors to be used for the markers.
Defaults to None.
• icon_colors (list, optional) – A list of colors to be used for the icons. Defaults
to [‘white’].
• icon_names (list, optional) – A list of names to be used for the icons. More
icons can be found at https://fontawesome.com/v4/icons or https://getbootstrap.com/docs/
3.3/components/?utm_source=pocket_mylist. Defaults to [‘info’].
• angle (int, optional) – The angle of the icon. Defaults to 0.
• prefix (str, optional) – The prefix states the source of the icon. ‘fa’ for font-
awesome or ‘glyphicon’ for bootstrap 3. Defaults to ‘fa’.
• add_legend (bool, optional) – If True, a legend will be added to the map. De-
faults to True.
add_raster(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, attribu-
tion=None, layer_name=’Local COG’, **kwargs)
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary
Computer), try adding to following two lines to the beginning of the notebook if the raster does
not render properly.
36 Chapter 4. Modules
geemap Documentation, Release 0.16.3
import os os.environ[‘LOCALTILESERVER_CLIENT_PREFIX’] =
f’{os.environ[‘JUPYTERHUB_SERVICE_PREFIX’].lstrip(‘/’)}/proxy/{{port}}’
Parameters
• source (str) – The path to the GeoTIFF file or the URL of the Cloud Optimized Geo-
TIFF.
• band (int, optional) – The band to use. Band indexing starts at 1. Defaults to
None.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to ‘Local COG’.
38 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• control (str, optional) – Adds the layer to the layer control. Defaults to True.
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• opacity (float, optional) – Sets the opacity for the layer.
• API_key (str, optional) – – API key for Cloudmade or Mapbox tiles. Defaults to
True.
add_time_slider(ee_object, vis_params={}, region=None, layer_name=’Time series’, la-
bels=None, time_interval=1, position=’bottomright’, slider_length=’150px’,
date_format=’YYYY-MM-dd’, opacity=1.0, **kwargs)
add_wms_layer(url, layers, name=None, attribution=”, overlay=True, control=True, shown=True,
format=’image/png’, transparent=True, version=’1.1.1’, styles=”, **kwargs)
Add a WMS layer to the map.
Parameters
• url (str) – The URL of the WMS web service.
• layers (str) – Comma-separated list of WMS layers to show.
• name (str, optional) – The layer name to use on the layer control. Defaults to
None.
• attribution (str, optional) – The attribution of the data layer. Defaults to ‘’.
• overlay (str, optional) – Allows overlay. Defaults to True.
• control (str, optional) – Adds the layer to the layer control. Defaults to True.
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• format (str, optional) – WMS image format (use ‘image/png’ for layers with
transparency). Defaults to ‘image/png’.
• transparent (bool, optional) – Whether the layer shall allow transparency. De-
faults to True.
• version (str, optional) – Version of the WMS service to use. Defaults to “1.1.1”.
• styles (str, optional) – Comma-separated list of WMS styles. Defaults to “”.
add_xyz_service(provider, **kwargs)
Add a XYZ tile layer to the map.
Parameters provider (str) – A tile layer name starts with xyz or qms. For example,
xyz.OpenTopoMap,
Raises ValueError – The provider is not valid. It must start with xyz or qms.
basemap_demo()
A demo for using geemap basemaps.
centerObject(ee_object, zoom=None)
Centers the map view on a given object.
Parameters
• ee_object (Element|Geometry) – An Earth Engine object to center on a geometry,
image or feature.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
center_object(ee_object, zoom=None)
Centers the map view on a given object.
Parameters
• ee_object (Element|Geometry) – An Earth Engine object to center on a geometry,
image or feature.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
dd_local_tile(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, attri-
bution=None, layer_name=’Local COG’, **kwargs)
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary
Computer), try adding to following two lines to the beginning of the notebook if the raster does
not render properly.
import os os.environ[‘LOCALTILESERVER_CLIENT_PREFIX’] =
f’{os.environ[‘JUPYTERHUB_SERVICE_PREFIX’].lstrip(‘/’)}/proxy/{{port}}’
Parameters
• source (str) – The path to the GeoTIFF file or the URL of the Cloud Optimized Geo-
TIFF.
• band (int, optional) – The band to use. Band indexing starts at 1. Defaults to
None.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to ‘Local COG’.
extract_values_to_points(filename)
publish(name=’Folium Map’, description=”, source_url=”, tags=None, source_file=None,
open=True, formatting=None, **kwargs)
Publish the map to datapane.com
Parameters
• name (str, optional) – The document name - can include spaces, caps, symbols,
etc., e.g. “Profit & Loss 2020”. Defaults to “Folium Map”.
• description (str, optional) – A high-level description for the document, this is
displayed in searches and thumbnails. Defaults to ‘’.
• source_url (str, optional) – A URL pointing to the source code for the docu-
ment, e.g. a GitHub repo or a Colab notebook. Defaults to ‘’.
40 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• tags (bool, optional) – A list of tags (as strings) used to categorise your document.
Defaults to None.
• source_file (str, optional) – Path of jupyter notebook file to upload. Defaults
to None.
• open (bool, optional) – Whether to open the map. Defaults to True.
• formatting (ReportFormatting, optional) – Set the basic styling for your
report.
remove_labels(**kwargs)
Removes a layer from the map.
setCenter(lon, lat, zoom=10)
Centers the map view at a given coordinates with the given zoom level.
Parameters
• lon (float) – The longitude of the center, in degrees.
• lat (float) – The latitude of the center, in degrees.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to 10.
setControlVisibility(layerControl=True, fullscreenControl=True, latLngPopup=True)
Sets the visibility of the controls on the map.
Parameters
• layerControl (bool, optional) – Whether to show the control that allows the
user to toggle layers on/off. Defaults to True.
• fullscreenControl (bool, optional) – Whether to show the control that al-
lows the user to make the map full-screen. Defaults to True.
• latLngPopup (bool, optional) – Whether to show the control that pops up the
Lat/lon when the user clicks on the map. Defaults to True.
setOptions(mapTypeId=’HYBRID’, styles={}, types=[])
Adds Google basemap to the map.
Parameters
• mapTypeId (str, optional) – A mapTypeId to set the basemap to. Can be one of
“ROADMAP”, “SATELLITE”, “HYBRID” or “TERRAIN” to select one of the standard
Google Maps API map types. Defaults to ‘HYBRID’.
• styles ([type], optional) – A dictionary of custom MapTypeStyle objects keyed
with a name that will appear in the map’s Map Type Controls. Defaults to None.
• types ([type], optional) – A list of mapTypeIds to make available. If omitted,
but opt_styles is specified, appends all of the style keys to the standard Google Maps API
map types.. Defaults to None.
set_center(lon, lat, zoom=10)
Centers the map view at a given coordinates with the given zoom level.
Parameters
• lon (float) – The longitude of the center, in degrees.
• lat (float) – The latitude of the center, in degrees.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to 10.
42 Chapter 4. Modules
geemap Documentation, Release 0.16.3
st_last_draw(st_component)
Get the last draw feature of the map.
Parameters st_folium (streamlit-folium) – The streamlit component.
Returns The last draw of the map.
Return type str
st_map_bounds(st_component)
Get the bounds of the map in the format of (miny, minx, maxy, maxx).
Parameters st_folium (streamlit-folium) – The streamlit component.
Returns The bounds of the map.
Return type tuple
st_map_center(st_component)
Get the center of the map.
Parameters st_folium (streamlit-folium) – The streamlit component.
Returns The center of the map.
Return type tuple
to_html(filename=None, **kwargs)
Exports a map as an HTML file.
Parameters filename (str, optional) – File path to the output HTML. Defaults to
None.
Raises ValueError – If it is an invalid HTML file.
Returns A string containing the HTML code.
Return type str
to_streamlit(width=1000, height=650, responsive=True, scrolling=False,
add_layer_control=True, bidirectional=False, **kwargs)
Renders folium.Figure or folium.Map in a Streamlit app. This method is a static Streamlit Component,
meaning, no information is passed back from Leaflet on browser interaction.
Parameters
• width (int, optional) – Width of the map. Defaults to 1000.
• height (int, optional) – Height of the map. Defaults to 650.
• responsive (bool, optional) – Whether to make the map responsive. Defaults to
True.
• scrolling (bool, optional) – Whether to allow the map to scroll. Defaults to
False.
• add_layer_control (bool, optional) – Whether to add the layer control. De-
faults to True.
• bidirectional (bool, optional) – Whether to add bidirectional functionality to
the map. The streamlit-folium package is required to use the bidirectional functionality.
Defaults to False.
Raises ImportError – If streamlit is not installed.
Returns components.html object.
Return type streamlit.components
layer_right: Layer. The left Layer within the side by side control. Must be created and added to the map before
being passed to this class.
name [string, default None] The name of the Layer, as it will appear in LayerControls.
overlay [bool, default True] Adds the layer as an optional overlay (True) or the base layer (False).
control [bool, default True] Whether the Layer will be included in LayerControls.
show: bool, default True Whether the layer will be shown on opening (only for overlays).
Examples
render(**kwargs)
Renders the HTML representation of the element.
geemap.foliumap.delete_dp_report(name)
Deletes a datapane report.
Parameters name (str) – Name of the report to delete.
geemap.foliumap.delete_dp_reports()
Deletes all datapane reports.
geemap.foliumap.ee_tile_layer(ee_object, vis_params={}, name=’Layer untitled’, shown=True,
opacity=1.0, **kwargs)
Converts and Earth Engine layer to ipyleaflet TileLayer.
Parameters
• ee_object (Collection|Feature|Image|MapId) – The object to add to the
map.
• vis_params (dict, optional) – The visualization parameters. Defaults to {}.
44 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• name (str, optional) – The name of the layer. Defaults to ‘Layer untitled’.
• shown (bool, optional) – A flag indicating whether the layer should be on by default.
Defaults to True.
• opacity (float, optional) – The layer’s opacity represented as a number between
0 and 1. Defaults to 1.
geemap.foliumap.linked_maps(rows=2, cols=2, height=’400px’, ee_objects=[], vis_params=[], la-
bels=[], label_position=’topright’, **kwargs)
geemap.foliumap.st_map_center(lat, lon)
Returns the map center coordinates for a given latitude and longitude. If the system variable ‘map_center’ exists,
it is used. Otherwise, the default is returned.
Parameters
• lat (float) – Latitude.
• lon (float) – Longitude.
Raises Exception – If streamlit is not installed.
Returns The map center coordinates.
Return type list
geemap.foliumap.st_save_bounds(st_component)
Saves the map bounds to the session state.
Parameters map (folium.folium.Map) – The map to save the bounds from.
Main module for interactive mapping using Google Earth Engine Python API and ipyleaflet. Keep in mind that Earth
Engine functions use both camel case and snake case, such as setOptions(), setCenter(), centerObject(), addLayer().
ipyleaflet functions use snake case, such as add_tile_layer(), add_wms_layer(), add_minimap().
class geemap.geemap.ImageOverlay(**kwargs)
Bases: ipyleaflet.leaflet.ImageOverlay
ImageOverlay class.
Parameters
• url (str) – http URL or local file path to the image.
• bounds (tuple) – bounding box of the image in the format of (lower_left(lat, lon), up-
per_right(lat, lon)), such as ((13, -130), (32, -100)).
• name (str) – The name of the layer.
class geemap.geemap.Map(**kwargs)
Bases: ipyleaflet.leaflet.Map
The Map class inherits from ipyleaflet.Map. The arguments you can pass to the Map can be found at https:
//ipyleaflet.readthedocs.io/en/latest/api_reference/map.html. By default, the Map will add Google Maps as the
basemap. Set add_google_map = False to use OpenStreetMap as the basemap.
Returns ipyleaflet map object.
Return type object
addLayer(ee_object, vis_params={}, name=None, shown=True, opacity=1.0)
Adds a given EE object to the map as a layer.
Parameters
• ee_object (Collection|Feature|Image|MapId) – The object to add to the
map.
• vis_params (dict, optional) – The visualization parameters. Defaults to {}.
• name (str, optional) – The name of the layer. Defaults to ‘Layer N’.
• shown (bool, optional) – A flag indicating whether the layer should be on by de-
fault. Defaults to True.
• opacity (float, optional) – The layer’s opacity represented as a number between
0 and 1. Defaults to 1.
addLayerControl()
Adds the layer control to the map.
add_basemap(basemap=’HYBRID’)
Adds a basemap to the map.
Parameters basemap (str, optional) – Can be one of string from basemaps. Defaults to
‘HYBRID’.
add_census_data(wms, layer, census_dict=None, **kwargs)
Adds a census data layer to the map.
Parameters
• wms (str) – The wms to use. For example, “Current”, “ACS 2021”, “Census 2020”. See
the complete list at https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_wms.html
• layer (str) – The layer name to add to the map.
• census_dict (dict, optional) – A dictionary containing census data. Defaults
to None. It can be obtained from the get_census_dict() function.
add_circle_markers_from_xy(data, x=’longitude’, y=’latitude’, radius=10, popup=None,
**kwargs)
Adds a marker cluster to the map. For a list of options, see https://ipyleaflet.readthedocs.io/en/latest/api_
reference/circle_marker.html
Parameters
• data (str | pd.DataFrame) – A csv or Pandas DataFrame containing x, y, z values.
• x (str, optional) – The column name for the x values. Defaults to “longitude”.
• y (str, optional) – The column name for the y values. Defaults to “latitude”.
• radius (int, optional) – The radius of the circle. Defaults to 10.
• popup (list, optional) – A list of column names to be used as the popup. Defaults
to None.
add_cog_layer(url, name=’Untitled’, attribution=”, opacity=1.0, shown=True, bands=None,
titiler_endpoint=’https://titiler.xyz’, **kwargs)
Adds a COG TileLayer to the map.
Parameters
• url (str) – The URL of the COG tile layer.
• name (str, optional) – The layer name to use for the layer. Defaults to ‘Untitled’.
• attribution (str, optional) – The attribution to use. Defaults to ‘’.
46 Chapter 4. Modules
geemap Documentation, Release 0.16.3
Parameters
• colors (list) – The set of colors to be used for interpolation. Colors can be provided
in the form: * tuples of RGBA ints between 0 and 255 (e.g: (255, 255, 0) or (255, 255,
0, 255)) * tuples of RGBA floats between 0. and 1. (e.g: (1.,1.,0.) or (1., 1., 0., 1.)) *
HTML-like string (e.g: “#ffff00) * a color name or shortcut (e.g: “y” or “yellow”)
• vmin (int, optional) – The minimal value for the colormap. Values lower than
vmin will be bound directly to colors[0].. Defaults to 0.
• vmax (float, optional) – The maximal value for the colormap. Values higher than
vmax will be bound directly to colors[-1]. Defaults to 1.0.
• index (list, optional) – The values corresponding to each color. It has to be
sorted, and have the same length as colors. If None, a regular grid between vmin and
vmax is created.. Defaults to None.
• caption (str, optional) – The caption for the colormap. Defaults to “”.
• categorical (bool, optional) – Whether or not to create a categorical colormap.
Defaults to False.
• step (int, optional) – The step to split the LinearColormap into a StepColormap.
Defaults to None.
• height (str, optional) – The height of the colormap widget. Defaults to “45px”.
• transparent_bg (bool, optional) – Whether to use transparent background for
the colormap widget. Defaults to True.
• position (str, optional) – The position for the colormap widget. Defaults to
“bottomright”.
• layer_name (str, optional) – Layer name of the colorbar to be associated with.
Defaults to None.
add_data(data, column, colors=None, labels=None, cmap=None, scheme=’Quantiles’, k=5,
add_legend=True, legend_title=None, legend_kwds=None, classification_kwds=None,
layer_name=’Untitled’, style=None, hover_style=None, style_callback=None,
info_mode=’on_hover’, encoding=’utf-8’, **kwargs)
Add vector data to the map with a variety of classification schemes.
Parameters
• data (str | pd.DataFrame | gpd.GeoDataFrame) – The data to classify. It
can be a filepath to a vector dataset, a pandas dataframe, or a geopandas geodataframe.
• column (str) – The column to classify.
• cmap (str, optional) – The name of a colormap recognized by matplotlib. Defaults
to None.
• colors (list, optional) – A list of colors to use for the classification. Defaults to
None.
• labels (list, optional) – A list of labels to use for the legend. Defaults to None.
• scheme (str, optional) – Name of a choropleth classification scheme (requires
mapclassify). Name of a choropleth classification scheme (requires mapclassify). A
mapclassify.MapClassifier object will be used under the hood. Supported are all
schemes provided by mapclassify (e.g. ‘BoxPlot’, ‘EqualInterval’, ‘FisherJenks’, ‘Fisher-
JenksSampled’, ‘HeadTailBreaks’, ‘JenksCaspall’, ‘JenksCaspallForced’, ‘JenksCaspall-
Sampled’, ‘MaxP’, ‘MaximumBreaks’, ‘NaturalBreaks’, ‘Quantiles’, ‘Percentiles’, ‘Std-
Mean’, ‘UserDefined’). Arguments can be passed in classification_kwds.
48 Chapter 4. Modules
geemap Documentation, Release 0.16.3
labels [list-like] A list of legend labels to override the auto-generated labblels. Needs to
have the same number of elements as the number of classes (k).
interval [boolean (default False)] An option to control brackets from mapclassify legend.
If True, open/closed interval brackets are shown in the legend.
50 Chapter 4. Modules
geemap Documentation, Release 0.16.3
52 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• label (str, optional) – A label to show on the GIF, such as place name. Defaults
to None.
• start_year (int, optional) – Starting year for the timelapse. Defaults to 1984.
• end_year (int, optional) – Ending year for the timelapse. Defaults to 2021.
• start_date (str, optional) – Starting date (month-day) each year for filtering
ImageCollection. Defaults to ‘06-10’.
• end_date (str, optional) – Ending date (month-day) each year for filtering Im-
ageCollection. Defaults to ‘09-20’.
• bands (list, optional) – Three bands selected from [‘Blue’, ‘Green’, ‘Red’,
‘NIR’, ‘SWIR1’, ‘SWIR2’, ‘pixel_qa’]. Defaults to [‘NIR’, ‘Red’, ‘Green’].
• vis_params (dict, optional) – Visualization parameters. Defaults to None.
• dimensions (int, optional) – a number or pair of numbers in format WIDTHx-
HEIGHT) Maximum dimensions of the thumbnail to render, in pixels. If only one number
is passed, it is used as the maximum, and the other dimension is computed by proportional
scaling. Defaults to 768.
• frames_per_second (int, optional) – Animation speed. Defaults to 10.
• font_size (int, optional) – Font size of the animated text and label. Defaults to
30.
• font_color (str, optional) – Font color of the animated text and label. Defaults
to ‘black’.
• add_progress_bar (bool, optional) – Whether to add a progress bar at the
bottom of the GIF. Defaults to True.
• progress_bar_color (str, optional) – Color for the progress bar. Defaults to
‘white’.
• progress_bar_height (int, optional) – Height of the progress bar. Defaults
to 5.
• out_gif (str, optional) – File path to the output animated GIF. Defaults to None.
• download (bool, optional) – Whether to download the gif. Defaults to False.
• apply_fmask (bool, optional) – Whether to apply Fmask (Function of mask) for
automated clouds, cloud shadows, snow, and water masking.
• nd_bands (list, optional) – A list of names specifying the bands to use, e.g.,
[‘Green’, ‘SWIR1’]. The normalized difference is computed as (first second) / (first +
second). Note that negative input values are forced to 0 so that the result is confined to the
range (-1, 1).
• nd_threshold (float, optional) – The threshold for extacting pixels from the
normalized difference band.
• nd_palette (str, optional) – The color palette to use for displaying the normal-
ized difference band.
add_layer_control()
Adds the layer control to the map.
add_legend(title=’Legend’, legend_dict=None, labels=None, colors=None, position=’bottomright’,
builtin_legend=None, layer_name=None, **kwargs)
Adds a customized basemap to the map.
Parameters
• title (str, optional) – Title of the legend. Defaults to ‘Legend’.
• legend_dict (dict, optional) – A dictionary containing legend items as keys
and color as values. If provided, legend_keys and legend_colors will be ignored. Defaults
to None.
• labels (list, optional) – A list of legend keys. Defaults to None.
• colors (list, optional) – A list of legend colors. Defaults to None.
• position (str, optional) – Position of the legend. Defaults to ‘bottomright’.
• builtin_legend (str, optional) – Name of the builtin legend to add to the map.
Defaults to None.
• layer_name (str, optional) – Layer name of the legend to be associated with.
Defaults to None.
add_local_tile(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, attri-
bution=None, layer_name=None, **kwargs)
Add a local raster dataset to the map.
Parameters
• source (str) – The path to the GeoTIFF file or the URL of the Cloud Optimized Geo-
TIFF.
• band (int, optional) – The band to use. Band indexing starts at 1. Defaults to
None.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to None.
add_marker(location, **kwargs)
Adds a marker to the map. More info about marker at https://ipyleaflet.readthedocs.io/en/latest/api_
reference/marker.html.
Parameters
• location (list | tuple) – The location of the marker in the format of [lat, lng].
• **kwargs – Keyword arguments for the marker.
add_marker_cluster(event=’click’, add_marker=True)
Captures user inputs and add markers to the map.
Parameters
• event (str, optional) – [description]. Defaults to ‘click’.
• add_marker (bool, optional) – If True, add markers to the map. Defaults to True.
54 Chapter 4. Modules
geemap Documentation, Release 0.16.3
Parameters
• filename (str) – File path or HTTP URL to the netCDF file.
• variables (int, optional) – The variable/band names to extract data from the
netCDF file. Defaults to None. If None, all variables will be extracted.
• port (str, optional) – The port to use for the server. Defaults to “default”.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to “netCDF layer”.
• shift_lon (bool, optional) – Flag to shift longitude values from [0, 360] to the
range [-180, 180]. Defaults to True.
• lat (str, optional) – Name of the latitude variable. Defaults to ‘lat’.
• lon (str, optional) – Name of the longitude variable. Defaults to ‘lon’.
56 Chapter 4. Modules
geemap Documentation, Release 0.16.3
58 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
add_osm_from_point(center_point, tags, dist=1000, layer_name=’Untitled’, style={},
hover_style={}, style_callback=None, fill_colors=[’black’],
info_mode=’on_hover’)
Adds OSM entities within some distance N, S, E, W of a point to the map.
Parameters
• center_point (tuple) – The (lat, lng) center point around which to get the geome-
tries.
• tags (dict) – Dict of tags used for finding objects in the selected area. Results returned
are the union, not intersection of each individual tag. Each result matches at least one
given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and
the dict values should be either True to retrieve all items with the given tag, or a string
to get a single tag-value combination, or a list of strings to get multiple values for the
given tag. For example, tags = {‘building’: True} would return all building footprints in
the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’}
would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop.
• dist (int, optional) – Distance in meters. Defaults to 1000.
• layer_name (str, optional) – The layer name to be used.. Defaults to “Untitled”.
• style (dict, optional) – A dictionary specifying the style to be used. Defaults to
{}.
• hover_style (dict, optional) – Hover style dictionary. Defaults to {}.
• style_callback (function, optional) – Styling function that is called for
each feature, and should return the feature style. This styling function takes the feature
as argument. Defaults to None.
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
add_osm_from_polygon(polygon, tags, layer_name=’Untitled’, style={}, hover_style={},
style_callback=None, fill_colors=[’black’], info_mode=’on_hover’)
Adds OSM entities within boundaries of a (multi)polygon to the map.
Parameters
• polygon (shapely.geometry.Polygon | shapely.geometry.
MultiPolygon) – Geographic boundaries to fetch geometries within
• tags (dict) – Dict of tags used for finding objects in the selected area. Results returned
are the union, not intersection of each individual tag. Each result matches at least one
given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and
the dict values should be either True to retrieve all items with the given tag, or a string
to get a single tag-value combination, or a list of strings to get multiple values for the
given tag. For example, tags = {‘building’: True} would return all building footprints in
60 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• month (int, optional) – The month of Planet global mosaic, must be 1-12. Defaults
to 1.
• name (str, optional) – The layer name to use. Defaults to None.
• api_key (str, optional) – The Planet API key. Defaults to None.
• token_name (str, optional) – The environment variable name of the API key.
Defaults to “PLANET_API_KEY”.
add_planet_by_quarter(year=2016, quarter=1, name=None, api_key=None, to-
ken_name=’PLANET_API_KEY’)
Adds a Planet global mosaic by quarter to the map. To get a Planet API key, see https://developers.planet.
com/quickstart/apis
Parameters
• year (int, optional) – The year of Planet global mosaic, must be >=2016. Defaults
to 2016.
• quarter (int, optional) – The quarter of Planet global mosaic, must be 1-12.
Defaults to 1.
• name (str, optional) – The layer name to use. Defaults to None.
• api_key (str, optional) – The Planet API key. Defaults to None.
• token_name (str, optional) – The environment variable name of the API key.
Defaults to “PLANET_API_KEY”.
add_point_layer(filename, popup=None, layer_name=’Marker Cluster’, **kwargs)
Adds a point layer to the map with a popup attribute.
Parameters
• filename (str) – str, http url, path object or file-like object. Either the absolute or
relative path to the file or URL to be opened, or any object with a read() method (such as
an open file or StringIO)
• popup (str | list, optional) – Column name(s) to be used for popup. Defaults
to None.
• layer_name (str, optional) – A layer name to use. Defaults to “Marker Cluster”.
Raises
• ValueError – If the specified column name does not exist.
• ValueError – If the specified column names do not exist.
add_points_from_xy(data, x=’longitude’, y=’latitude’, popup=None, layer_name=’Marker Clus-
ter’, color_column=None, marker_colors=None, icon_colors=[’white’],
icon_names=[’info’], spin=False, add_legend=True, **kwargs)
Adds a marker cluster to the map.
Parameters
• data (str | pd.DataFrame) – A csv or Pandas DataFrame containing x, y, z values.
• x (str, optional) – The column name for the x values. Defaults to “longitude”.
• y (str, optional) – The column name for the y values. Defaults to “latitude”.
• popup (list, optional) – A list of column names to be used as the popup. Defaults
to None.
• layer_name (str, optional) – The name of the layer. Defaults to “Marker Clus-
ter”.
• color_column (str, optional) – The column name for the color values. Defaults
to None.
• marker_colors (list, optional) – A list of colors to be used for the markers.
Defaults to None.
• icon_colors (list, optional) – A list of colors to be used for the icons. Defaults
to [‘white’].
• icon_names (list, optional) – A list of names to be used for the icons. More
icons can be found at https://fontawesome.com/v4/icons. Defaults to [‘info’].
• spin (bool, optional) – If True, the icon will spin. Defaults to False.
• add_legend (bool, optional) – If True, a legend will be added to the map. De-
faults to True.
add_raster(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, attribu-
tion=None, layer_name=None, **kwargs)
Add a local raster dataset to the map.
Parameters
• source (str) – The path to the GeoTIFF file or the URL of the Cloud Optimized Geo-
TIFF.
• band (int, optional) – The band to use. Band indexing starts at 1. Defaults to
None.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to None.
add_raster_legacy(image, bands=None, layer_name=None, colormap=None, x_dim=’x’,
y_dim=’y’)
Adds a local raster dataset to the map.
Parameters
• image (str) – The image file path.
• bands (int or list, optional) – The image bands to use. It can be either a
number (e.g., 1) or a list (e.g., [3, 2, 1]). Defaults to None.
• layer_name (str, optional) – The layer name to use for the raster. Defaults to
None.
62 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• colormap (str, optional) – The name of the colormap to use for the raster, such
as ‘gray’ and ‘terrain’. More can be found at https://matplotlib.org/3.1.0/tutorials/colors/
colormaps.html. Defaults to None.
• x_dim (str, optional) – The x dimension. Defaults to ‘x’.
• y_dim (str, optional) – The y dimension. Defaults to ‘y’.
add_remote_tile(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, at-
tribution=None, layer_name=None, **kwargs)
Add a remote Cloud Optimized GeoTIFF (COG) to the map.
Parameters
• source (str) – The path to the remote Cloud Optimized GeoTIFF.
• band (int, optional) – The band to use. Band indexing starts at 1. Defaults to
None.
• palette (str, optional) – The name of the color palette from palettable to use
when plotting a single band. See https://jiffyclub.github.io/palettable. Default is greyscale
• vmin (float, optional) – The minimum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• vmax (float, optional) – The maximum value to use when colormapping the
palette when plotting a single band. Defaults to None.
• nodata (float, optional) – The value from the band to use to interpret as not valid
data. Defaults to None.
• attribution (str, optional) – Attribution for the source raster. This defaults to
a message about it being a local file.. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to None.
add_shapefile(in_shp, layer_name=’Untitled’, style={}, hover_style={}, style_callback=None,
fill_colors=[’black’], info_mode=’on_hover’, encoding=’utf-8’)
Adds a shapefile to the map.
Parameters
• in_shp (str) – The input file path to the shapefile.
• layer_name (str, optional) – The layer name to be used.. Defaults to “Untitled”.
• style (dict, optional) – A dictionary specifying the style to be used. Defaults to
{}.
• hover_style (dict, optional) – Hover style dictionary. Defaults to {}.
• style_callback (function, optional) – Styling function that is called for
each feature, and should return the feature style. This styling function takes the feature
as argument. Defaults to None.
• fill_colors (list, optional) – The random colors to use for filling polygons.
Defaults to [“black”].
• info_mode (str, optional) – Displays the attributes by either on_hover or
on_click. Any value other than “on_hover” or “on_click” will be treated as None. De-
faults to “on_hover”.
• encoding (str, optional) – The encoding of the shapefile. Defaults to “utf-8”.
Raises FileNotFoundError – The provided shapefile could not be found.
64 Chapter 4. Modules
geemap Documentation, Release 0.16.3
66 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• y (str, optional) – The name of the column containing latitude coordinates. De-
faults to “latitude”.
• label (str, optional) – The name of the column containing label information to
used for marker popup. Defaults to None.
• layer_name (str, optional) – The layer name to use. Defaults to “Marker clus-
ter”.
• to_ee (bool, optional) – Whether to convert the csv to an ee.FeatureCollection.
Raises
• FileNotFoundError – The specified input csv does not exist.
• ValueError – The specified x column does not exist.
• ValueError – The specified y column does not exist.
• ValueError – The specified label column does not exist.
add_xyz_service(provider, **kwargs)
Add a XYZ tile layer to the map.
Parameters provider (str) – A tile layer name starts with xyz or qms. For example,
xyz.OpenTopoMap,
Raises ValueError – The provider is not valid. It must start with xyz or qms.
basemap_demo()
A demo for using geemap basemaps.
centerObject(ee_object, zoom=None)
Centers the map view on a given object.
Parameters
• ee_object (Element|Geometry) – An Earth Engine object to center on a geometry,
image or feature.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
center_object(ee_object, zoom=None)
Centers the map view on a given object.
Parameters
• ee_object (Element|Geometry) – An Earth Engine object to center on a geometry,
image or feature.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
create_vis_widget(layer_dict)
Create a GUI for changing layer visualization parameters interactively.
Parameters layer_dict (dict) – A dict containning information about the layer. It is an
element from Map.ee_layer_dict.
Returns An ipywidget.
Return type object
draw_layer_on_top()
Move user-drawn feature layer to the top of all layers.
extract_values_to_points(filename)
Exports pixel values to a csv file based on user-drawn geometries.
68 Chapter 4. Modules
geemap Documentation, Release 0.16.3
Parameters filename (str) – The output file path to the csv file or shapefile.
find_layer(name)
Finds layer by name
Parameters name (str) – Name of the layer to find.
Returns ipyleaflet layer object.
Return type object
find_layer_index(name)
Finds layer index by name
Parameters name (str) – Name of the layer to find.
Returns Index of the layer with the specified name
Return type int
getBounds(asGeoJSON=False)
Returns the bounds of the current map view, as a list in the format [west, south, east, north] in degrees.
Parameters asGeoJSON (bool, optional) – If true, returns map bounds as GeoJSON.
Defaults to False.
Returns A list in the format [west, south, east, north] in degrees.
Return type list | dict
getScale()
Returns the approximate pixel scale of the current map view, in meters.
Returns Map resolution in meters.
Return type float
get_bounds(asGeoJSON=False)
Returns the bounds of the current map view, as a list in the format [west, south, east, north] in degrees.
Parameters asGeoJSON (bool, optional) – If true, returns map bounds as GeoJSON.
Defaults to False.
Returns A list in the format [west, south, east, north] in degrees.
Return type list | dict
get_scale()
Returns the approximate pixel scale of the current map view, in meters.
Returns Map resolution in meters.
Return type float
image_overlay(url, bounds, name)
Overlays an image from the Internet or locally on the map.
Parameters
• url (str) – http URL or local file path to the image.
• bounds (tuple) – bounding box of the image in the format of (lower_left(lat, lon),
upper_right(lat, lon)), such as ((13, -130), (32, -100)).
• name (str) – name of the layer to show on the layer control.
layer_opacity(name, value=1.0)
Changes layer opacity.
Parameters
• name (str) – The name of the layer to change opacity.
• value (float, optional) – The opacity value to set. Defaults to 1.0.
marker_cluster()
Adds a marker cluster to the map and returns a list of ee.Feature, which can be accessed using
Map.ee_marker_cluster.
Returns a list of ee.Feature
Return type object
plot(x, y, plot_type=None, overlay=False, position=’bottomright’, min_width=None,
max_width=None, min_height=None, max_height=None, **kwargs)
Creates a plot based on x-array and y-array data.
Parameters
• x (numpy.ndarray or list) – The x-coordinates of the plotted line.
• y (numpy.ndarray or list) – The y-coordinates of the plotted line.
• plot_type (str, optional) – The plot type can be one of “None”, “bar”, “scatter”
or “hist”. Defaults to None.
• overlay (bool, optional) – Whether to overlay plotted lines on the figure. De-
faults to False.
• position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottom-
right’, ‘topleft’, or ‘topright’. Defaults to ‘bottomright’.
• min_width (int, optional) – Min width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_width (int, optional) – Max width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• min_height (int, optional) – Min height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_height (int, optional) – Max height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
plot_demo(iterations=20, plot_type=None, overlay=False, position=’bottomright’, min_width=None,
max_width=None, min_height=None, max_height=None, **kwargs)
A demo of interactive plotting using random pixel coordinates.
Parameters
• iterations (int, optional) – How many iterations to run for the demo. Defaults
to 20.
• plot_type (str, optional) – The plot type can be one of “None”, “bar”, “scatter”
or “hist”. Defaults to None.
• overlay (bool, optional) – Whether to overlay plotted lines on the figure. De-
faults to False.
• position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottom-
right’, ‘topleft’, or ‘topright’. Defaults to ‘bottomright’.
• min_width (int, optional) – Min width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
70 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• max_width (int, optional) – Max width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• min_height (int, optional) – Min height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_height (int, optional) – Max height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
plot_raster(ee_object=None, sample_scale=None, plot_type=None, overlay=False, posi-
tion=’bottomright’, min_width=None, max_width=None, min_height=None,
max_height=None, **kwargs)
Interactive plotting of Earth Engine data by clicking on the map.
Parameters
• ee_object (object, optional) – The ee.Image or ee.ImageCollection to sample.
Defaults to None.
• sample_scale (float, optional) – A nominal scale in meters of the projection
to sample in. Defaults to None.
• plot_type (str, optional) – The plot type can be one of “None”, “bar”, “scatter”
or “hist”. Defaults to None.
• overlay (bool, optional) – Whether to overlay plotted lines on the figure. De-
faults to False.
• position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottom-
right’, ‘topleft’, or ‘topright’. Defaults to ‘bottomright’.
• min_width (int, optional) – Min width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_width (int, optional) – Max width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• min_height (int, optional) – Min height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_height (int, optional) – Max height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
remove_colorbar()
Remove colorbar from the map.
remove_colorbars()
Remove all colorbars from the map.
remove_drawn_features()
Removes user-drawn geometries from the map
remove_ee_layer(name)
Removes an Earth Engine layer.
Parameters name (str) – The name of the Earth Engine layer to remove.
remove_labels()
Removes all labels from the map.
remove_last_drawn()
Removes user-drawn geometries from the map
remove_legend()
Remove legend from the map.
remove_legends()
Remove all legends from the map.
setCenter(lon, lat, zoom=None)
Centers the map view at a given coordinates with the given zoom level.
Parameters
• lon (float) – The longitude of the center, in degrees.
• lat (float) – The latitude of the center, in degrees.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
setControlVisibility(layerControl=True, fullscreenControl=True, latLngPopup=True)
Sets the visibility of the controls on the map.
Parameters
• layerControl (bool, optional) – Whether to show the control that allows the
user to toggle layers on/off. Defaults to True.
• fullscreenControl (bool, optional) – Whether to show the control that al-
lows the user to make the map full-screen. Defaults to True.
• latLngPopup (bool, optional) – Whether to show the control that pops up the
Lat/lon when the user clicks on the map. Defaults to True.
setOptions(mapTypeId=’HYBRID’, styles=None, types=None)
Adds Google basemap and controls to the ipyleaflet map.
Parameters
• mapTypeId (str, optional) – A mapTypeId to set the basemap to. Can be one of
“ROADMAP”, “SATELLITE”, “HYBRID” or “TERRAIN” to select one of the standard
Google Maps API map types. Defaults to ‘HYBRID’.
• styles (object, optional) – A dictionary of custom MapTypeStyle objects keyed
with a name that will appear in the map’s Map Type Controls. Defaults to None.
• types (list, optional) – A list of mapTypeIds to make available. If omitted, but
opt_styles is specified, appends all of the style keys to the standard Google Maps API map
types.. Defaults to None.
set_center(lon, lat, zoom=None)
Centers the map view at a given coordinates with the given zoom level.
Parameters
• lon (float) – The longitude of the center, in degrees.
• lat (float) – The latitude of the center, in degrees.
• zoom (int, optional) – The zoom level, from 1 to 24. Defaults to None.
set_control_visibility(layerControl=True, fullscreenControl=True, latLngPopup=True)
Sets the visibility of the controls on the map.
Parameters
• layerControl (bool, optional) – Whether to show the control that allows the
user to toggle layers on/off. Defaults to True.
• fullscreenControl (bool, optional) – Whether to show the control that al-
lows the user to make the map full-screen. Defaults to True.
72 Chapter 4. Modules
geemap Documentation, Release 0.16.3
• latLngPopup (bool, optional) – Whether to show the control that pops up the
Lat/lon when the user clicks on the map. Defaults to True.
set_options(mapTypeId=’HYBRID’, styles=None, types=None)
Adds Google basemap and controls to the ipyleaflet map.
Parameters
• mapTypeId (str, optional) – A mapTypeId to set the basemap to. Can be one of
“ROADMAP”, “SATELLITE”, “HYBRID” or “TERRAIN” to select one of the standard
Google Maps API map types. Defaults to ‘HYBRID’.
• styles (object, optional) – A dictionary of custom MapTypeStyle objects keyed
with a name that will appear in the map’s Map Type Controls. Defaults to None.
• types (list, optional) – A list of mapTypeIds to make available. If omitted, but
opt_styles is specified, appends all of the style keys to the standard Google Maps API map
types.. Defaults to None.
set_plot_options(add_marker_cluster=False, sample_scale=None, plot_type=None, over-
lay=False, position=’bottomright’, min_width=None, max_width=None,
min_height=None, max_height=None, **kwargs)
Sets plotting options.
Parameters
• add_marker_cluster (bool, optional) – Whether to add a marker cluster. De-
faults to False.
• sample_scale (float, optional) – A nominal scale in meters of the projection
to sample in . Defaults to None.
• plot_type (str, optional) – The plot type can be one of “None”, “bar”, “scatter”
or “hist”. Defaults to None.
• overlay (bool, optional) – Whether to overlay plotted lines on the figure. De-
faults to False.
• position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottom-
right’, ‘topleft’, or ‘topright’. Defaults to ‘bottomright’.
• min_width (int, optional) – Min width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_width (int, optional) – Max width of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• min_height (int, optional) – Min height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
• max_height (int, optional) – Max height of the widget (in pixels), if None it will
respect the content size. Defaults to None.
split_map(left_layer=’HYBRID’, right_layer=’ROADMAP’)
Adds split map.
Parameters
• left_layer (str, optional) – The layer tile layer. Defaults to ‘HYBRID’.
• right_layer (str, optional) – The right tile layer. Defaults to ‘ROADMAP’.
to_html(filename=None, title=’My Map’, width=’100%’, height=’880px’, add_layer_control=True,
**kwargs)
Saves the map as an HTML file.
Parameters
• filename (str, optional) – The output file path to the HTML file.
• title (str, optional) – The title of the HTML file. Defaults to ‘My Map’.
• width (str, optional) – The width of the map in pixels or percentage. Defaults to
‘100%’.
• height (str, optional) – The height of the map in pixels. Defaults to ‘880px’.
• add_layer_control (bool, optional) – Whether to add the LayersControl. De-
faults to True.
to_image(filename=None, monitor=1)
Saves the map as a PNG or JPG image.
Parameters
• filename (str, optional) – The output file path to the image. Defaults to None.
• monitor (int, optional) – The monitor to take the screenshot. Defaults to 1.
to_streamlit(width=700, height=500, responsive=True, scrolling=False, **kwargs)
Renders map figure in a Streamlit app.
Parameters
• width (int, optional) – Width of the map. Defaults to 700.
• height (int, optional) – Height of the map. Defaults to 500.
• responsive (bool, optional) – Whether to make the map responsive. Defaults to
True.
• scrolling (bool, optional) – If True, show a scrollbar when the content is larger
than the iframe. Otherwise, do not show a scrollbar. Defaults to False.
Returns components.html object.
Return type streamlit.components
toolbar_reset()
Reset the toolbar so that no tool is selected.
ts_inspector(left_ts, left_names=None, left_vis={}, right_ts=None, right_names=None,
right_vis=None, width=’130px’, date_format=’YYYY-MM-dd’, **kwargs)
Creates a split-panel map for inspecting timeseries images.
Parameters
• left_ts (object) – An ee.ImageCollection to show on the left panel.
• left_names (list) – A list of names to show under the left dropdown.
• left_vis (dict, optional) – Visualization parameters for the left layer. Defaults
to {}.
• right_ts (object) – An ee.ImageCollection to show on the right panel.
• right_names (list) – A list of names to show under the right dropdown.
• right_vis (dict, optional) – Visualization parameters for the right layer. De-
faults to {}.
• width (str, optional) – The width of the dropdown list. Defaults to ‘130px’.
74 Chapter 4. Modules
geemap Documentation, Release 0.16.3
user_roi_coords(decimals=4)
Return the bounding box of the ROI as a list of coordinates.
Parameters decimals (int, optional) – Number of decimals to round the coordinates
to. Defaults to 4.
video_overlay(url, bounds, name=’Video’)
Overlays a video from the Internet on the map.
Parameters
• url (str) – http URL of the video, such as “https://www.mapbox.com/bites/00188/
patricia_nasa.webm”
• bounds (tuple) – bounding box of the video in the format of (lower_left(lat, lon),
upper_right(lat, lon)), such as ((13, -130), (32, -100)).
• name (str) – name of the layer to show on the layer control.
zoom_to_bounds(bounds)
Zooms to a bounding box in the form of [minx, miny, maxx, maxy].
Parameters bounds (list | tuple) – A list/tuple containing minx, miny, maxx, maxy
values for the bounds.
zoom_to_gdf(gdf )
Zooms to the bounding box of a GeoPandas GeoDataFrame.
Parameters gdf (GeoDataFrame) – A GeoPandas GeoDataFrame.
zoom_to_me(zoom=14, add_marker=True)
Zoom to the current device location.
Parameters
• zoom (int, optional) – Zoom level. Defaults to 14.
• add_marker (bool, optional) – Whether to add a marker of the current device
location. Defaults to True.
geemap.geemap.ee_tile_layer(ee_object, vis_params={}, name=’Layer untitled’, shown=True,
opacity=1.0)
Converts and Earth Engine layer to ipyleaflet TileLayer.
Parameters
• ee_object (Collection|Feature|Image|MapId) – The object to add to the
map.
• vis_params (dict, optional) – The visualization parameters. Defaults to {}.
• name (str, optional) – The name of the layer. Defaults to ‘Layer untitled’.
• shown (bool, optional) – A flag indicating whether the layer should be on by default.
Defaults to True.
• opacity (float, optional) – The layer’s opacity represented as a number between
0 and 1. Defaults to 1.
geemap.geemap.linked_maps(rows=2, cols=2, height=’400px’, ee_objects=[], vis_params=[], la-
bels=[], label_position=’topright’, **kwargs)
Create linked maps of Earth Engine data layers.
Parameters
• rows (int, optional) – The number of rows of maps to create. Defaults to 2.
76 Chapter 4. Modules
CHAPTER 5
Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants
to implement it.
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to
whoever wants to implement it.
77
geemap Documentation, Release 0.16.3
geemap could always use more documentation, whether as part of the official geemap docs, in docstrings, or even on
the web in blog posts, articles, and such.
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development:
$ mkvirtualenv geemap
$ cd geemap/
$ python setup.py develop
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub:
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
78 Chapter 5. Contributing
geemap Documentation, Release 0.16.3
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function
with a docstring, and add the feature to the list in README.rst.
3. The pull request should work for Python 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.com/giswqs/
geemap/pull_requests and make sure that the tests pass for all supported Python versions.
5.4 Tips
5.5 Deploying
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in
HISTORY.rst). Then run:
80 Chapter 5. Contributing
CHAPTER 6
Credits
• Qiusheng Wu
6.2 Contributors
• Cesar Aybar
• Oliver Burdekin
• Diego Garcia Diaz
• Justin Braaten
81
geemap Documentation, Release 0.16.3
82 Chapter 6. Credits
CHAPTER 7
History
83
geemap Documentation, Release 0.16.3
84 Chapter 7. History
CHAPTER 8
• genindex
• modindex
• search
85
geemap Documentation, Release 0.16.3
87
geemap Documentation, Release 0.16.3
88 Index
geemap Documentation, Release 0.16.3
Index 89
geemap Documentation, Release 0.16.3
set_plot_options() (geemap.foliumap.Map V
method), 42 video_overlay() (geemap.geemap.Map method),
set_plot_options() (geemap.geemap.Map 75
method), 73
setCenter() (geemap.foliumap.Map method), 41 X
setCenter() (geemap.geemap.Map method), 72 xyz_to_folium() (in module geemap.basemaps), 20
setControlVisibility() (geemap.foliumap.Map xyz_to_heremap() (in module geemap.basemaps),
method), 41 20
setControlVisibility() (geemap.geemap.Map xyz_to_leaflet() (in module geemap.basemaps),
method), 72 20
setOptions() (geemap.foliumap.Map method), 41 xyz_to_plotly() (in module geemap.basemaps), 20
setOptions() (geemap.geemap.Map method), 72 xyz_to_pydeck() (in module geemap.basemaps), 20
split_map() (geemap.foliumap.Map method), 42
split_map() (geemap.geemap.Map method), 73 Z
SplitControl (class in geemap.foliumap), 44
zoom_to_bounds() (geemap.foliumap.Map method),
st_draw_features() (geemap.foliumap.Map
44
method), 42
zoom_to_bounds() (geemap.geemap.Map method),
st_fit_bounds() (geemap.foliumap.Map method),
75
42
zoom_to_gdf() (geemap.foliumap.Map method), 44
st_last_click() (geemap.foliumap.Map method),
zoom_to_gdf() (geemap.geemap.Map method), 75
42
zoom_to_me() (geemap.geemap.Map method), 75
st_last_draw() (geemap.foliumap.Map method), 42
st_map_bounds() (geemap.foliumap.Map method),
43
st_map_center() (geemap.foliumap.Map method),
43
st_map_center() (in module geemap.foliumap), 45
st_save_bounds() (in module geemap.foliumap), 45
T
template_footer() (in module
geemap.conversion), 23
template_header() (in module
geemap.conversion), 23
to_html() (geemap.foliumap.Map method), 43
to_html() (geemap.geemap.Map method), 73
to_image() (geemap.geemap.Map method), 74
to_streamlit() (geemap.foliumap.Map method), 43
to_streamlit() (geemap.geemap.Map method), 74
toolbar_reset() (geemap.geemap.Map method),
74
ts_inspector() (geemap.foliumap.Map method), 44
ts_inspector() (geemap.geemap.Map method), 74
ts_inspector() (in module geemap.geemap), 76
U
update_nb_header() (in module
geemap.conversion), 23
update_nb_header_dir() (in module
geemap.conversion), 24
use_folium() (in module geemap), 76
use_math() (in module geemap.conversion), 24
user_roi_coords() (geemap.geemap.Map
method), 74
90 Index