geemap package

Submodules

geemap.basemaps module

Module for basemaps. Each basemap is defined as item in the ee_basemaps dictionary. For example, to access Google basemaps, use the following:

ee_basemaps[‘ROADMAP’], ee_basemaps[‘SATELLITE’], ee_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.cli module

Console script for geemap.

geemap.conversion module

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)[source]

Extracts Earth Engine map function

Parameters:input_lines (list) – List of Earth Engine JavaScrips
Returns:Output JavaScript with map function
Return type:list
geemap.conversion.convert_for_loop(line)[source]

Converts JavaScript for loop to Python for loop.

Parameters:line (str) – Input JavaScript for loop
Returns:Converted Python for loop.
Return type:str
geemap.conversion.create_new_cell(contents, replace=False)[source]

Create a new cell in Jupyter notebook based on the contents.

Parameters:contents (str) – A string of Python code.
geemap.conversion.download_gee_app(url, out_file=None)[source]

Downloads JavaScript source code from a GEE App

Parameters:
  • url (str) – The URL of the GEE App.
  • out_file (str, optional) – The output file path for the downloaded JavaScript. Defaults to None.
geemap.conversion.execute_notebook(in_file)[source]

Executes a Jupyter notebook and save output cells

Parameters:in_file (str) – Input Jupyter notebook.
geemap.conversion.execute_notebook_dir(in_dir)[source]

Executes all Jupyter notebooks in the given directory recursively and save output cells.

Parameters:in_dir (str) – Input folder containing notebooks.
geemap.conversion.find_matching_bracket(lines, start_line_index, start_char_index, matching_char='{')[source]

Finds the position of the matching closing bracket from a list of lines.

Parameters:
  • lines (list) – The input list of lines.
  • start_line_index (int) – The line index where the starting bracket is located.
  • start_char_index (int) – The position index of the starting bracket.
  • matching_char (str, optional) – The starting bracket to search for. Defaults to ‘{‘.
Returns:

The line index where the matching closing bracket is located. matching_char_index (int): The position index of the matching closing bracket.

Return type:

matching_line_index (int)

geemap.conversion.format_params(line, sep=':')[source]

Formats keys in a dictionary and adds quotes to the keys. For example, {min: 0, max: 10} will result in (‘min’: 0, ‘max’: 10)

Parameters:
  • line (str) – A string.
  • sep (str, optional) – Separator. Defaults to ‘:’.
Returns:

A string with keys quoted

Return type:

[str]

geemap.conversion.get_js_examples(out_dir=None)[source]

Gets Earth Engine JavaScript examples from the geemap package.

Parameters:out_dir (str, optional) – The folder to copy the JavaScript examples to. Defaults to None.
Returns:The folder containing the JavaScript examples.
Return type:str
geemap.conversion.get_nb_template(download_latest=False, out_file=None)[source]

Get the Earth Engine Jupyter notebook template.

Parameters:
  • download_latest (bool, optional) – If True, downloads the latest notebook template from GitHub. Defaults to False.
  • out_file (str, optional) – Set the output file path of the notebook template. Defaults to None.
Returns:

The file path of the template.

Return type:

str

geemap.conversion.js_snippet_to_py(in_js_snippet, add_new_cell=True, import_ee=True, import_geemap=True, show_map=True)[source]

Converts an Earth Engine JavaScript snippet wrapped in triple quotes to Python directly on a Jupyter notebook.

Parameters:
  • in_js_snippet (str) – Earth Engine JavaScript within triple quotes.
  • add_new_cell (bool, optional) – Whether add the converted Python to a new cell.
  • import_ee (bool, optional) – Whether to import ee. Defaults to True.
  • import_geemap (bool, optional) – Whether to import geemap. Defaults to True.
  • show_map (bool, optional) – Whether to show the map. Defaults to True.
Returns:

A list of Python script.

Return type:

list

geemap.conversion.js_to_python(in_file, out_file=None, use_qgis=True, github_repo=None)[source]

Converts an Earth Engine JavaScript to Python script.

Args:
in_file (str): File path of the input JavaScript. out_file (str, optional): File path of the output Python script. 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.
Returns:
list: Python script
geemap.conversion.js_to_python_dir(in_dir, out_dir=None, use_qgis=True, github_repo=None)[source]

Converts all Earth Engine JavaScripts in a folder recursively to Python scripts.

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.
geemap.conversion.py_to_ipynb(in_file, template_file, out_file=None, github_username=None, github_repo=None)[source]

Converts Earth Engine Python script to Jupyter notebook.

Parameters:
  • in_file (str) – Input Earth Engine Python script.
  • template_file (str) – Input Jupyter notebook template.
  • out_file (str, optional)) – Output Jupyter notebook.
  • github_username (str, optional) – GitHub username. Defaults to None.
  • github_repo (str, optional) – GitHub repo name. Defaults to None.
geemap.conversion.py_to_ipynb_dir(in_dir, template_file, out_dir=None, github_username=None, github_repo=None)[source]

Converts Earth Engine Python scripts in a folder recursively to Jupyter notebooks.

Parameters:
  • in_dir (str) – Input folder containing Earth Engine Python scripts.
  • template_file (str) – Input jupyter notebook template file.
  • str, optional) (out_dir) – Output folder. Defaults to None.
  • github_username (str, optional) – GitHub username. Defaults to None.
  • github_repo (str, optional) – GitHub repo name. Defaults to None.
geemap.conversion.remove_qgis_import(in_file)[source]

Removes ‘from ee_plugin import Map’ from an Earth Engine Python script.

Parameters:in_file (str) – Input file path of the Python script.
Returns:List of lines ‘from ee_plugin import Map’ removed.
Return type:list

Extracts footer from the notebook template.

Parameters:in_template (str) – Input notebook template file path.
Returns:List of lines.
Return type:list
geemap.conversion.template_header(in_template)[source]

Extracts header from the notebook template.

Parameters:in_template (str) – Input notebook template file path.
Returns:List of lines.
Return type:list
geemap.conversion.update_nb_header(in_file, github_username=None, github_repo=None)[source]

Updates notebook header (binder and Google Colab URLs).

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)[source]

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)[source]

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]

geemap.eefolium module

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.eefolium.Map(**kwargs)[source]

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 default. 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.

add_COG_layer(url, name='Untitled', attribution='.', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', **kwargs)[source]

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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
add_COG_mosaic(links, name='Untitled', attribution='.', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', username='anonymous', overwrite=False, show_footprints=False, verbose=True, **kwargs)[source]

Add a virtual mosaic of COGs to the map.

Parameters:
  • links (list) – A list of links pointing to COGs.
  • 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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
  • username (str, optional) – The username to create mosaic using the titiler endpoint. Defaults to ‘anonymous’.
  • overwrite (bool, optional) – Whether or not to replace existing layer with the same layer name. Defaults to False.
  • show_footprints (bool, optional) – Whether or not to show footprints of COGs. Defaults to False.
  • verbose (bool, optional) – Whether or not to print descriptions. Defaults to True.
add_STAC_layer(url, bands=None, name='Untitled', attribution='.', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', **kwargs)[source]

Adds a STAC 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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
add_basemap(basemap='HYBRID')[source]

Adds a basemap to the map.

Parameters:basemap (str, optional) – Can be one of string from ee_basemaps. Defaults to ‘HYBRID’.
add_colorbar(colors, vmin=0, vmax=1.0, index=None, caption='', categorical=False, step=None, **kwargs)[source]

Add a colorbar to the map.

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.
add_geojson(in_geojson, layer_name='Untitled', **kwargs)[source]

Adds a GeoJSON file to the map.

Parameters:
  • in_geojson (str) – The input file path to the GeoJSON.
  • layer_name (str, optional) – The layer name to be used. Defaults to “Untitled”.
Raises:

FileNotFoundError – The provided GeoJSON file could not be found.

add_kml(in_kml, layer_name='Untitled', **kwargs)[source]

Adds a KML file to the map.

Parameters:
  • in_kml (str) – The input file path to the KML.
  • layer_name (str, optional) – The layer name to be used. Defaults to “Untitled”.
Raises:

FileNotFoundError – The provided KML file could not be found.

add_layer(ee_object, vis_params={}, name='Layer untitled', shown=True, opacity=1.0, **kwargs)[source]

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 default. Defaults to True.
  • opacity (float, optional) – The layer’s opacity represented as a number between 0 and 1. Defaults to 1.
add_layer_control()[source]

Adds layer control to the map.

add_legend(title='Legend', colors=None, labels=None, legend_dict=None, builtin_legend=None, opacity=1.0, **kwargs)[source]

Adds a customized basemap to the map. Reference: https://bit.ly/3oV6vnH

Parameters:
  • title (str, optional) – Title of the legend. Defaults to ‘Legend’. Defaults to “Legend”.
  • colors ([type], optional) – A list of legend colors. Defaults to None.
  • labels ([type], optional) – A list of legend labels. Defaults to None.
  • legend_dict ([type], 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 ([type], 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_shapefile(in_shp, layer_name='Untitled', **kwargs)[source]

Adds a shapefile to the map. See https://python-visualization.github.io/folium/modules.html#folium.features.GeoJson for more info about setting style.

Parameters:
  • in_shp (str) – The input file path to the shapefile.
  • layer_name (str, optional) – The layer name to be used. Defaults to “Untitled”.
Raises:

FileNotFoundError – The provided shapefile could not be found.

add_styled_vector(ee_object, column, palette, layer_name='Untitled', **kwargs)[source]

Adds a styled vector to the map.

Parameters:
  • ee_object (object) – An ee.FeatureCollection.
  • column (str) – The column name to use for styling.
  • palette (list | dict) – The palette (e.g., list of colors or a dict containing label and color pairs) to use for styling.
  • layer_name (str, optional) – The name to be used for the new layer. Defaults to “Untitled”.
add_tile_layer(tiles='OpenStreetMap', name='Untitled', attribution='.', overlay=True, control=True, shown=True, opacity=1.0, API_key=None, **kwargs)[source]

Add a XYZ tile layer to the map.

Parameters:
  • tiles (str) – The URL of the XYZ tile service.
  • name (str, optional) – The layer name to use on the layer control. Defaults to ‘Untitled’.
  • 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 default. 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_wms_layer(url, layers, name=None, attribution='', overlay=True, control=True, shown=True, format='image/png', transparent=False, version='1.1.1', styles='', **kwargs)[source]

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 default. 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. Defaults to False.
  • 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 “”.
centerObject(ee_object, zoom=10)

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 10.
center_object(ee_object, zoom=10)[source]

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 10.
publish(name='Folium Map', description='', source_url='', visibility='PUBLIC', open=True, tags=None, **kwargs)[source]

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 document, e.g. a GitHub repo or a Colab notebook. Defaults to ‘’.
  • visibility (str, optional) – Visibility of the map. It can be one of the following: PUBLIC, PRIVATE. Defaults to ‘PUBLIC’.
  • open (bool, optional) – Whether to open the map. Defaults to True.
  • tags (bool, optional) – A list of tags (as strings) used to categorise your document. Defaults to None.
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 allows 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=[])[source]

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)[source]

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.
set_control_visibility(layerControl=True, fullscreenControl=True, latLngPopup=True)[source]

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 allows 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.
set_options(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.
geemap.eefolium.delete_dp_report(name)[source]

Deletes a datapane report.

Parameters:name (str) – Name of the report to delete.
geemap.eefolium.delete_dp_reports()[source]

Deletes all datapane reports.

geemap.geemap module

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.Map(**kwargs)[source]

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 default. 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_COG_layer(url, name='Untitled', attribution='', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', **kwargs)[source]

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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
add_COG_mosaic(links, name='Untitled', attribution='', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', username='anonymous', overwrite=False, show_footprints=False, verbose=True, **kwargs)[source]

Add a virtual mosaic of COGs to the map.

Parameters:
  • links (list) – A list of links pointing to COGs.
  • 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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
  • username (str, optional) – The username to create mosaic using the titiler endpoint. Defaults to ‘anonymous’.
  • overwrite (bool, optional) – Whether or not to replace existing layer with the same layer name. Defaults to False.
  • show_footprints (bool, optional) – Whether or not to show footprints of COGs. Defaults to False.
  • verbose (bool, optional) – Whether or not to print descriptions. Defaults to True.
add_STAC_layer(url, bands=None, name='Untitled', attribution='', opacity=1.0, shown=True, titiler_endpoint='https://api.cogeo.xyz/', **kwargs)[source]

Adds a STAC 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 default. Defaults to True.
  • titiler_endpoint (str, optional) – Titiler endpoint. Defaults to “https://api.cogeo.xyz/”.
add_basemap(basemap='HYBRID')[source]

Adds a basemap to the map.

Parameters:basemap (str, optional) – Can be one of string from ee_basemaps. Defaults to ‘HYBRID’.
add_colorbar(vis_params=None, cmap='gray', discrete=False, label=None, orientation='horizontal', position='bottomright', transparent_bg=False, layer_name=None, **kwargs)[source]

Add a matplotlib colorbar to the map

Parameters:
  • vis_params (dict) – Visualization parameters as a dictionary. See https://developers.google.com/earth-engine/guides/image_visualization for options.
  • cmap (str, optional) – Matplotlib colormap. Defaults to “gray”. See https://matplotlib.org/3.3.4/tutorials/colors/colormaps.html#sphx-glr-tutorials-colors-colormaps-py for options.
  • discrete (bool, optional) – Whether to create a discrete colorbar. Defaults to False.
  • label (str, optional) – Label for the colorbar. Defaults to None.
  • orientation (str, optional) – Orientation of the colorbar, such as “vertical” and “horizontal”. Defaults to “horizontal”.
  • position (str, optional) – Position of the colorbar on the map. It can be one of: topleft, topright, bottomleft, and bottomright. Defaults to “bottomright”.
  • transparent_bg (bool, optional) – Whether to use transparent background. Defaults to False.
  • layer_name (str, optional) – The layer name associated with the colorbar. Defaults to None.
Raises:
  • TypeError – If the vis_params is not a dictionary.
  • ValueError – If the orientation is not either horizontal or vertical.
  • ValueError – If the provided min value is not scalar type.
  • ValueError – If the provided max value is not scalar type.
  • ValueError – If the provided opacity value is not scalar type.
  • ValueError – If cmap or palette is not provided.
add_colorbar_branca(colors, vmin=0, vmax=1.0, index=None, caption='', categorical=False, step=None, height='45px', transparent_bg=False, position='bottomright', layer_name=None, **kwargs)[source]

Add a branca colorbar to the map.

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_ee_layer(ee_object, vis_params={}, name=None, shown=True, opacity=1.0)[source]

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 default. Defaults to True.
  • opacity (float, optional) – The layer’s opacity represented as a number between 0 and 1. Defaults to 1.
add_geojson(in_geojson, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=['black'], info_mode='on_hover')[source]

Adds a GeoJSON file to the map.

Parameters:
  • in_geojson (str | dict) – The file path or http URL to the input GeoJSON or a dictionary containing the geojson.
  • 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. Defaults to “on_hover”.
Raises:

FileNotFoundError – The provided GeoJSON file could not be found.

add_kml(in_kml, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=['black'], info_mode='on_hover')[source]

Adds a GeoJSON file to the map.

Parameters:
  • in_kml (str) – The input file path to the KML.
  • 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. Defaults to “on_hover”.
Raises:

FileNotFoundError – The provided KML file could not be found.

add_landsat_ts_gif(layer_name='Timelapse', roi=None, label=None, start_year=1984, end_year=2019, start_date='06-10', end_date='09-20', bands=['NIR', 'Red', 'Green'], vis_params=None, dimensions=768, frames_per_second=10, font_size=30, font_color='white', add_progress_bar=True, progress_bar_color='white', progress_bar_height=5, out_gif=None, download=False, apply_fmask=True, nd_bands=None, nd_threshold=0, nd_palette=['black', 'blue'])[source]

Adds a Landsat timelapse to the map.

Parameters:
  • layer_name (str, optional) – Layer name to show under the layer control. Defaults to ‘Timelapse’.
  • roi (object, optional) – Region of interest to create the timelapse. Defaults to None.
  • label (str, optional) – A label to shown 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 2019.
  • 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 ImageCollection. 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 WIDTHxHEIGHT) 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 normalized difference band.
add_layer_control()[source]

Adds the layer control to the map.

add_legend(legend_title='Legend', legend_dict=None, legend_keys=None, legend_colors=None, position='bottomright', builtin_legend=None, layer_name=None, **kwargs)[source]

Adds a customized basemap to the map.

Parameters:
  • legend_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.
  • legend_keys (list, optional) – A list of legend keys. Defaults to None.
  • legend_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_maker_cluster(event='click', add_marker=True)[source]

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.
Returns:

a marker cluster.

Return type:

object

add_minimap(zoom=5, position='bottomright')[source]

Adds a minimap (overview) to the ipyleaflet map.

Parameters:
  • zoom (int, optional) – Initial map zoom level. Defaults to 5.
  • position (str, optional) – Position of the minimap. Defaults to “bottomright”.
add_raster(image, bands=None, layer_name=None, colormap=None, x_dim='x', y_dim='y')[source]

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 nubmer (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.
  • 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_shapefile(in_shp, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=['black'], info_mode='on_hover')[source]

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. Defaults to “on_hover”.
Raises:

FileNotFoundError – The provided shapefile could not be found.

add_styled_vector(ee_object, column, palette, layer_name='Untitled', **kwargs)[source]

Adds a styled vector to the map.

Parameters:
  • ee_object (object) – An ee.FeatureCollection.
  • column (str) – The column name to use for styling.
  • palette (list | dict) – The palette (e.g., list of colors or a dict containing label and color pairs) to use for styling.
  • layer_name (str, optional) – The name to be used for the new layer. Defaults to “Untitled”.
add_tile_layer(url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', name='Untitled', attribution='', opacity=1.0, shown=True, **kwargs)[source]

Adds a TileLayer to the map.

Parameters:
  • url (str, optional) – The URL of the tile layer. Defaults to ‘https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’.
  • 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 default. Defaults to True.
add_time_slider(ee_object, vis_params={}, region=None, layer_name='Time series', labels=None, time_interval=1, position='bottomright', slider_length='150px', date_format='YYYY-MM-dd')[source]

Adds a time slider to the map.

Parameters:
  • ee_object (ee.Image | ee.ImageCollection) – The Image or ImageCollection to visualize.
  • vis_params (dict, optional) – Visualization parameters to use for visualizing image. Defaults to {}.
  • region (ee.Geometry | ee.FeatureCollection) – The region to visualize.
  • layer_name (str, optional) – The layer name to be used. Defaults to “Time series”.
  • labels (list, optional) – The list of labels to be used for the time series. Defaults to None.
  • time_interval (int, optional) – Time interval in seconds. Defaults to 1.
  • position (str, optional) – Position to place the time slider, can be any of [‘topleft’, ‘topright’, ‘bottomleft’, ‘bottomright’]. Defaults to “bottomright”.
  • slider_length (str, optional) – Length of the time slider. Defaults to “150px”.
  • date_format (str, optional) – The date format to use. Defaults to ‘YYYY-MM-dd’.
Raises:

TypeError – If the ee_object is not ee.Image | ee.ImageCollection.

add_vector(filename, layer_name='Untitled', to_ee=False, bbox=None, mask=None, rows=None, style={}, hover_style={}, style_callback=None, fill_colors=['black'], info_mode='on_hover', **kwargs)[source]

Adds any geopandas-supported vector dataset to the map.

Parameters:
  • filename (str) – 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).
  • layer_name (str, optional) – The layer name to use. Defaults to “Untitled”.
  • to_ee (bool, optional) – Whether to convert the GeoJSON to ee.FeatureCollection. Defaults to False.
  • bbox (tuple | GeoDataFrame or GeoSeries | shapely Geometry, optional) – Filter features by given bounding box, GeoSeries, GeoDataFrame or a shapely geometry. CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame. Cannot be used with mask. Defaults to None.
  • mask (dict | GeoDataFrame or GeoSeries | shapely Geometry, optional) – Filter for features that intersect with the given dict-like geojson geometry, GeoSeries, GeoDataFrame or shapely geometry. CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame. Cannot be used with bbox. Defaults to None.
  • rows (int or slice, optional) – Load in specific rows by passing an integer (first n rows) or a slice() object.. Defaults to None.
  • 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. Defaults to “on_hover”.
add_wms_layer(url, layers, name=None, attribution='', format='image/jpeg', transparent=False, opacity=1.0, shown=True, **kwargs)[source]

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 ‘’.
  • format (str, optional) – WMS image format (use ‘image/png’ for layers with transparency). Defaults to ‘image/jpeg’.
  • transparent (bool, optional) – If True, the WMS service will return images with transparency. Defaults to False.
  • opacity (float, optional) – The opacity of the layer. Defaults to 1.0.
  • shown (bool, optional) – A flag indicating whether the layer should be on by default. Defaults to True.
add_xy_data(in_csv, x='longitude', y='latitude', label=None, layer_name='Marker cluster', to_ee=False)[source]

Adds points from a CSV file containing lat/lon information and display data on the map.

Parameters:
  • in_csv (str) – The file path to the input CSV file.
  • x (str, optional) – The name of the column containing longitude coordinates. Defaults to “longitude”.
  • y (str, optional) – The name of the column containing latitude coordinates. Defaults 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 cluster”.
  • 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.
basemap_demo()[source]

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)[source]

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)[source]

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()[source]

Move user-drawn feature layer to the top of all layers.

extract_values_to_points(filename)[source]

Exports pixel values to a csv file based on user-drawn geometries.

Parameters:filename (str) – The output file path to the csv file or shapefile.
find_layer(name)[source]

Finds layer by name

Parameters:name (str) – Name of the layer to find.
Returns:ipyleaflet layer object.
Return type:object
find_layer_index(name)[source]

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
getScale()

Returns the approximate pixel scale of the current map view, in meters.

Returns:Map resolution in meters.
Return type:float
get_scale()[source]

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)[source]

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)[source]

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()[source]

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)[source]

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. Defaults to False.
  • position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘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)[source]

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. Defaults to False.
  • position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘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_raster(ee_object=None, sample_scale=None, plot_type=None, overlay=False, position='bottomright', min_width=None, max_width=None, min_height=None, max_height=None, **kwargs)[source]

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. Defaults to False.
  • position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘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()[source]

Remove colorbar from the map.

remove_drawn_features()[source]

Removes user-drawn geometries from the map

remove_ee_layer(name)[source]

Removes an Earth Engine layer.

Parameters:name (str) – The name of the Earth Engine layer to remove.
remove_last_drawn()[source]

Removes user-drawn geometries 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 allows 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)[source]

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)[source]

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 allows 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.
set_options(mapTypeId='HYBRID', styles=None, types=None)[source]

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, overlay=False, position='bottomright', min_width=None, max_width=None, min_height=None, max_height=None, **kwargs)[source]

Sets plotting options.

Parameters:
  • add_marker_cluster (bool, optional) – Whether to add a marker cluster. Defaults 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. Defaults to False.
  • position (str, optional) – Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘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='ESRI')[source]

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 ‘ESRI’.
to_html(outfile, title='My Map', width='100%', height='880px', add_layer_control=True)[source]

Saves the map as a HTML file.

Parameters:
  • outfile (str) – 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. Defaults to True.
to_image(outfile=None, monitor=1)[source]

Saves the map as a PNG or JPG image.

Parameters:
  • outfile (str, optional) – The output file path to the image. Defaults to None.
  • monitor (int, optional) – The monitor to take the screenshot. Defaults to 1.
toolbar_reset()[source]

Reset the toolbar so that no tool is selected.

ts_inspector(left_ts, right_ts, left_names, right_names, left_vis={}, right_vis={})[source]

Creates a split-panel map for inspecting timeseries images.

Parameters:
  • left_ts (object) – An ee.ImageCollection to show on the left panel.
  • right_ts (object) – An ee.ImageCollection to show on the right panel.
  • left_names (list) – A list of names to show under the left dropdown.
  • right_names (list) – A list of names to show under the right dropdown.
  • left_vis (dict, optional) – Visualization parameters for the left layer. Defaults to {}.
  • right_vis (dict, optional) – Visualization parameters for the right layer. Defaults to {}.
video_overlay(url, bounds, name)[source]

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.
zoomToObject(ee_object)

Zoom to the full extent of an Earth Engine object.

Parameters:ee_object (object) – An Earth Engine object, such as Image, ImageCollection, Geometry, Feature, FeatureCollection.
Raises:Exception – Error getting geometry.
zoom_to_object(ee_object)[source]

Zoom to the full extent of an Earth Engine object.

Parameters:ee_object (object) – An Earth Engine object, such as Image, ImageCollection, Geometry, Feature, FeatureCollection.
Raises:Exception – Error getting geometry.
geemap.geemap.ee_tile_layer(ee_object, vis_params={}, name='Layer untitled', shown=True, opacity=1.0)[source]

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=[], labels=[], label_position='topright', **kwargs)[source]

Create linked maps of Earth Engine data layers.

Parameters:
  • rows (int, optional) – The number of rows of maps to create. Defaults to 2.
  • cols (int, optional) – The number of columns of maps to ceate. Defaults to 2.
  • height (str, optional) – The height of each map in pixels. Defaults to “400px”.
  • ee_objects (list, optional) – The list of Earth Engine objects to use for each map. Defaults to [].
  • vis_params (list, optional) – The list of visualization parameters to use for each map. Defaults to [].
  • labels (list, optional) – The list of labels to show on the map. Defaults to [].
  • label_position (str, optional) – The position of the label, can be [topleft, topright, bottomleft, bottomright]. Defaults to “topright”.
Raises:
  • ValueError – If the length of ee_objects is not equal to rows*cols.
  • ValueError – If the length of vis_params is not equal to rows*cols.
  • ValueError – If the length of labels is not equal to rows*cols.
Returns:

A GridspecLayout widget.

Return type:

ipywidget

geemap.legends module

Module of sample legends for some commonly used geospatial datasets.

geemap.legends.ee_table_to_legend(in_table, out_file)[source]

Converts an Earth Engine color table to a dictionary

Parameters:
  • in_table (str) – The input file path (*.txt) to the Earth Engine color table.
  • out_file (str) – The output file path (*.txt) to the legend dictionary.

Module contents

Top-level package for geemap.

geemap.use_folium()[source]

Whether to use the folium or ipyleaflet plotting backend.