Skip to content

stac module

leafmap.stac

PlanetaryComputerEndpoint

Bases: TitilerEndpoint

This class contains the methods for the Microsoft Planetary Computer endpoint.

__init__(endpoint='https://planetarycomputer.microsoft.com/api/data/v1', name='item', TileMatrixSetId='WebMercatorQuad')

Initialize the PlanetaryComputerEndpoint object.

Parameters:

Name Type Description Default
endpoint str

The endpoint of the titiler server. Defaults to "https://planetarycomputer.microsoft.com/api/data/v1".

'https://planetarycomputer.microsoft.com/api/data/v1'
name str

The name to be used in the file path. Defaults to "item".

'item'
TileMatrixSetId str

The TileMatrixSetId to be used in the file path. Defaults to "WebMercatorQuad".

'WebMercatorQuad'

TitilerCMREndpoint

This class contains the methods for the TiTiler CMR endpoint.

__init__(endpoint=None, TileMatrixSetId='WebMercatorQuad')

Initialize the TitilerCMREndpoint object.

Parameters:

Name Type Description Default
endpoint str

The TiTiler CMR endpoint URL. Defaults to "https://staging.openveda.cloud/api/titiler-cmr".

None
TileMatrixSetId str

The TileMatrixSetId. Defaults to "WebMercatorQuad".

'WebMercatorQuad'

url_for_statistics()

Get the URL for the statistics endpoint.

Returns:

Name Type Description
str

The statistics endpoint URL.

url_for_tilejson()

Get the URL for the TileJSON endpoint.

Returns:

Name Type Description
str

The TileJSON endpoint URL.

url_for_timeseries()

Get the URL for the time series endpoint.

Returns:

Name Type Description
str

The time series endpoint URL.

url_for_timeseries_gif(bbox, width=512, height=512)

Get the URL for the time series animated GIF endpoint.

Parameters:

Name Type Description Default
bbox list | tuple

Bounding box as [minx, miny, maxx, maxy].

required
width int

Width of the GIF in pixels. Defaults to 512.

512
height int

Height of the GIF in pixels. Defaults to 512.

512

Returns:

Name Type Description
str

The time series GIF endpoint URL.

url_for_timeseries_statistics()

Get the URL for the time series statistics endpoint.

Returns:

Name Type Description
str

The time series statistics endpoint URL.

url_for_timeseries_tilejson()

Get the URL for the time series TileJSON endpoint.

Returns:

Name Type Description
str

The time series TileJSON endpoint URL.

TitilerEndpoint

This class contains the methods for the titiler endpoint.

__init__(endpoint=None, name='stac', TileMatrixSetId='WebMercatorQuad')

Initialize the TiTilerEndpoint object.

Parameters:

Name Type Description Default
endpoint str

The endpoint of the titiler server. Defaults to "https://titiler.opengeos.org".

None
name str

The name to be used in the file path. Defaults to "stac".

'stac'
TileMatrixSetId str

The TileMatrixSetId to be used in the file path. Defaults to "WebMercatorQuad".

'WebMercatorQuad'

check_titiler_cmr_endpoint(titiler_cmr_endpoint=None)

Returns the TiTiler CMR endpoint.

Parameters:

Name Type Description Default
titiler_cmr_endpoint str

The TiTiler CMR endpoint URL. Defaults to None.

None

Returns:

Name Type Description
TitilerCMREndpoint TitilerCMREndpoint

The TiTiler CMR endpoint object.

check_titiler_endpoint(titiler_endpoint=None)

Returns the default titiler endpoint.

Returns:

Type Description
Any

The titiler endpoint.

cmr_animated_gif(concept_id, datetime, bbox, width=512, height=512, step='P1D', temporal_mode='point', backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, fps=1, output=None, titiler_cmr_endpoint=None, **kwargs)

Generate animated GIF for time series from TiTiler CMR.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime range (e.g., '2024-01-01/2024-01-31').

required
bbox list | tuple

Bounding box as [minx, miny, maxx, maxy].

required
width int

Width of the GIF in pixels. Defaults to 512.

512
height int

Height of the GIF in pixels. Defaults to 512.

512
step str

ISO 8601 duration for time steps (e.g., 'P1D' for 1 day, 'P1M' for 1 month). Defaults to 'P1D'.

'P1D'
temporal_mode str

Temporal mode - 'point' or 'range'. Defaults to 'point'.

'point'
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
bands str | list

Band name(s) for rasterio backend.

None
bands_regex str

Regex pattern for selecting bands (e.g., 'B[0-9][]').

None
expression str

Band math expression (e.g., '(B05-B04)/(B05+B04)').

None
rescale str | list

Min/max values for rescaling (e.g., '270,305' or [[270, 305]]).

None
colormap_name str

Name of colormap (e.g., 'thermal', 'viridis').

None
color_formula str

Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7').

None
fps int

Frames per second for the GIF. Defaults to 1.

1
output str

Output file path. If None, returns the URL.

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters.

{}

Returns:

Name Type Description
str str

The GIF URL or output file path.

cmr_bounds(concept_id, datetime=None, backend='rasterio', variable=None, titiler_cmr_endpoint=None, **kwargs)

Get bounding box from TiTiler CMR TileJSON.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31').

None
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters.

{}

Returns:

Name Type Description
list List[float]

Bounding box as [minx, miny, maxx, maxy].

cmr_center(concept_id, datetime=None, backend='rasterio', variable=None, titiler_cmr_endpoint=None, **kwargs)

Get center coordinates from TiTiler CMR TileJSON.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31').

None
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters.

{}

Returns:

Name Type Description
tuple Tuple[float, float]

Center coordinates as (longitude, latitude).

cmr_statistics(concept_id, datetime=None, geojson=None, backend='rasterio', variable=None, bands=None, titiler_cmr_endpoint=None, **kwargs)

Calculate statistics for an AOI from TiTiler CMR.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31').

None
geojson dict | str

GeoJSON geometry or file path for the AOI.

None
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
bands str | list

Band name(s) for rasterio backend.

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters.

{}

Returns:

Name Type Description
dict Dict

Statistics for the AOI.

cmr_tile(concept_id, datetime=None, backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)

Get tile URL from TiTiler CMR.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31').

None
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
bands str | list

Band name(s) for rasterio backend.

None
bands_regex str

Regex pattern for selecting bands (e.g., 'B[0-9][]').

None
expression str

Band math expression (e.g., '(B05-B04)/(B05+B04)').

None
rescale str | list

Min/max values for rescaling (e.g., '270,305' or [[270, 305]]).

None
colormap_name str

Name of colormap (e.g., 'thermal', 'viridis').

None
color_formula str

Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7').

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters to pass to the TiTiler CMR endpoint.

{}

Returns:

Name Type Description
str str

The tile URL template.

cmr_tilejson(concept_id, datetime=None, backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)

Fetch TileJSON metadata from TiTiler CMR.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31').

None
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
bands str | list

Band name(s) for rasterio backend.

None
bands_regex str

Regex pattern for selecting bands (e.g., 'B[0-9][]').

None
expression str

Band math expression (e.g., '(B05-B04)/(B05+B04)').

None
rescale str | list

Min/max values for rescaling (e.g., '270,305' or [[270, 305]]).

None
colormap_name str

Name of colormap (e.g., 'thermal', 'viridis').

None
color_formula str

Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7').

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters to pass to the TiTiler CMR endpoint.

{}

Returns:

Name Type Description
dict Dict

TileJSON metadata dict with tiles, bounds, center, minzoom, maxzoom.

cmr_timeseries_tilejson(concept_id, datetime, step='P1D', temporal_mode='point', backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)

Get time series TileJSON dict from TiTiler CMR.

Parameters:

Name Type Description Default
concept_id str

NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD').

required
datetime str

RFC3339 datetime range (e.g., '2024-01-01/2024-01-31').

required
step str

ISO 8601 duration for time steps (e.g., 'P1D' for 1 day, 'P1M' for 1 month, 'P2W' for 2 weeks). Defaults to 'P1D'.

'P1D'
temporal_mode str

Temporal mode - 'point' or 'range'. Defaults to 'point'.

'point'
backend str

Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'.

'rasterio'
variable str

Variable name for xarray backend datasets.

None
bands str | list

Band name(s) for rasterio backend.

None
bands_regex str

Regex pattern for selecting bands (e.g., 'B[0-9][]').

None
expression str

Band math expression (e.g., '(B05-B04)/(B05+B04)').

None
rescale str | list

Min/max values for rescaling (e.g., '270,305' or [[270, 305]]).

None
colormap_name str

Name of colormap (e.g., 'thermal', 'viridis').

None
color_formula str

Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7').

None
titiler_cmr_endpoint str

TiTiler CMR endpoint URL.

None
**kwargs

Additional parameters.

{}

Returns:

Name Type Description
dict Dict[str, Dict]

Dictionary mapping datetime strings to TileJSON metadata.

cog_bands(url, titiler_endpoint=None)

Get band names of a Cloud Optimized GeoTIFF (COG).

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None

Returns:

Type Description
List

A list of band names.

cog_bounds(url, titiler_endpoint=None)

Get the bounding box of a Cloud Optimized GeoTIFF (COG).

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None

Returns:

Name Type Description
list List

A list of values representing [left, bottom, right, top]

cog_center(url, titiler_endpoint=None)

Get the centroid of a Cloud Optimized GeoTIFF (COG).

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None

Returns:

Type Description
Tuple

A tuple representing (longitude, latitude).

cog_info(url, titiler_endpoint=None, return_geojson=False)

Get band statistics of a Cloud Optimized GeoTIFF (COG).

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None

Returns:

Name Type Description
list List

A dictionary of band info.

cog_mosaic(links, titiler_endpoint=None, username='anonymous', layername=None, overwrite=False, verbose=True, **kwargs)

Creates a COG mosaic from a list of COG URLs.

Parameters:

Name Type Description Default
links list

A list containing COG HTTP URLs.

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None
username str

User name for the titiler endpoint. Defaults to "anonymous".

'anonymous'
layername [type]

Layer name to use. Defaults to None.

None
overwrite bool

Whether to overwrite the layer name if existing. Defaults to False.

False
verbose bool

Whether to print out descriptive information. Defaults to True.

True

Raises:

Type Description
Exception

If the COG mosaic fails to create.

Returns:

Type Description
str

The tile URL for the COG mosaic.

cog_mosaic_from_file(filepath, skip_rows=0, titiler_endpoint=None, username='anonymous', layername=None, overwrite=False, verbose=True, **kwargs)

Creates a COG mosaic from a csv/txt file stored locally for through HTTP URL.

Parameters:

Name Type Description Default
filepath str

Local path or HTTP URL to the csv/txt file containing COG URLs.

required
skip_rows int

The number of rows to skip in the file. Defaults to 0.

0
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None
username str

User name for the titiler endpoint. Defaults to "anonymous".

'anonymous'
layername [type]

Layer name to use. Defaults to None.

None
overwrite bool

Whether to overwrite the layer name if existing. Defaults to False.

False
verbose bool

Whether to print out descriptive information. Defaults to True.

True

Returns:

Type Description
str

The tile URL for the COG mosaic.

cog_pixel_value(lon, lat, url, bidx, titiler_endpoint=None, verbose=True, **kwargs)

Get pixel value from COG.

Parameters:

Name Type Description Default
lon float

Longitude of the pixel.

required
lat float

Latitude of the pixel.

required
url str

HTTP URL to a COG, e.g., 'https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif'

required
bidx str

Dataset band indexes (e.g bidx=1, bidx=1&bidx=2&bidx=3). Defaults to None.

required
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None
verbose bool

Print status messages. Defaults to True.

True

Returns:

Name Type Description
list List

A dictionary of band info.

cog_stats(url, titiler_endpoint=None)

Get band statistics of a Cloud Optimized GeoTIFF (COG).

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None

Returns:

Name Type Description
list List

A dictionary of band statistics.

cog_tile(url, bands=None, titiler_endpoint=None, **kwargs)

Get a tile layer from a Cloud Optimized GeoTIFF (COG). Source code adapted from https://developmentseed.org/titiler/examples/notebooks/Working_with_CloudOptimizedGeoTIFF_simple/

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif. Default to None

required
bands list

List of bands to use. Defaults to None.

None
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None
**kwargs Any

Additional arguments to pass to the titiler endpoint. For more information about the available arguments, see https://developmentseed.org/titiler/endpoints/cog/#tiles. For example, to apply a rescaling to multiple bands, use something like rescale=["164,223","130,211","99,212"].

{}

Returns:

Type Description
Tuple

The COG tile layer URL and bounds.

cog_tile_vmin_vmax(url, bands=None, titiler_endpoint=None, percentile=True, **kwargs)

Get a tile layer from a Cloud Optimized GeoTIFF (COG) and return the minimum and maximum values.

Parameters:

Name Type Description Default
url str

HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif

required
bands list

List of bands to use. Defaults to None.

None
titiler_endpoint str

TiTiler endpoint. Defaults to "https://titiler.opengeos.org".

None
percentile bool

Whether to use percentiles or not. Defaults to True.

True

create_mosaicjson(images, output)

Create a mosaicJSON file from a list of images.

Parameters:

Name Type Description Default
images str | list

A list of image URLs or a URL to a text file containing a list of image URLs.

required
output str

The output mosaicJSON file path.

required

download_data_catalogs(out_dir=None, quiet=True, overwrite=False)

Download geospatial data catalogs from https://github.com/giswqs/geospatial-data-catalogs.

Parameters:

Name Type Description Default
out_dir str

The output directory. Defaults to None.

None
quiet bool

Whether to suppress the download progress bar. Defaults to True.

True
overwrite bool

Whether to overwrite the existing data catalog. Defaults to False.

False

Returns:

Name Type Description
str str

The path to the downloaded data catalog.

flatten_dict(my_dict, parent_key=False, sep='.')

Flattens a nested dictionary.

Parameters:

Name Type Description Default
my_dict dict

The dictionary to flatten.

required
parent_key bool

Whether to include the parent key. Defaults to False.

False
sep str

The separator to use. Defaults to '.'.

'.'

Returns:

Type Description
Dict[str, Any]

The flattened dictionary.

Retrieve the URL of the GeoTIFF asset from a STAC Item.

Parameters:

Name Type Description Default
item_url str

The URL to a STAC Item JSON.

required

Returns:

Type Description
str

URL of the first .tif asset, or None if not found.

maxar_all_items(collection_id, return_gdf=True, assets=['visual'], verbose=True, **kwargs)

Retrieve STAC items from Maxar's public STAC API.

Parameters:

Name Type Description Default
collection_id str

The collection ID, e.g., Kahramanmaras-turkey-earthquake-23 Use maxar_collections() to retrieve all available collection IDs.

required
return_gdf bool

If True, return a GeoDataFrame. Defaults to True.

True
assets list

A list of asset names to include in the GeoDataFrame. It can be "visual", "ms_analytic", "pan_analytic", "data-mask". Defaults to ['visual'].

['visual']
verbose bool

If True, print progress. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the pystac Catalog.from_file() method.

{}

Returns:

Type Description
Union[GeoDataFrame, List[Dict[str, Any]]]

If return_gdf is True, return a GeoDataFrame.

maxar_child_collections(collection_id, return_ids=True, **kwargs)

Get a list of Maxar child collections.

Parameters:

Name Type Description Default
collection_id str

The collection ID, e.g., Kahramanmaras-turkey-earthquake-23 Use maxar_collections() to retrieve all available collection IDs.

required
return_ids bool

Whether to return the collection ids. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the pystac Catalog.from_file() method.

{}

Returns:

Name Type Description
list List

A list of Maxar child collections.

maxar_collection_url(collection, dtype='geojson', raw=True)

Retrieve the URL to a Maxar Open Data collection.

Parameters:

Name Type Description Default
collection str

The collection ID, e.g., Kahramanmaras-turkey-earthquake-23. Use maxar_collections() to retrieve all available collection IDs.

required
dtype str

The data type. It can be 'geojson' or 'tsv'. Defaults to 'geojson'.

'geojson'
raw bool

If True, return the raw URL. Defaults to True.

True

Returns:

Type Description
str

The URL to the collection.

maxar_collections(return_ids=True, **kwargs)

Get a list of Maxar collections.

Parameters:

Name Type Description Default
return_ids bool

Whether to return the collection ids. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the pystac Catalog.from_file() method.

{}

Returns:

Name Type Description
list List

A list of Maxar collections.

maxar_download(images, out_dir=None, quiet=False, proxy=None, speed=None, use_cookies=True, verify=True, id=None, fuzzy=False, resume=False, overwrite=False)

Download Mxar Open Data images.

Parameters:

Name Type Description Default
images str | images

The list of image links or a file path to a geojson or tsv containing the Maxar download links.

required
out_dir str

The output directory. Defaults to None.

None
quiet bool

Suppress terminal output. Default is False.

False
proxy str

Proxy. Defaults to None.

None
speed float

Download byte size per second (e.g., 256KB/s = 256 * 1024). Defaults to None.

None
use_cookies bool

Flag to use cookies. Defaults to True.

True
verify bool | str

Either a bool, in which case it controls whether the server's TLS certificate is verified, or a string, in which case it must be a path to a CA bundle to use. Default is True.. Defaults to True.

True
id str

Google Drive's file ID. Defaults to None.

None
fuzzy bool

Fuzzy extraction of Google Drive's file Id. Defaults to False.

False
resume bool

Resume the download from existing tmp file if possible. Defaults to False.

False
overwrite bool

Overwrite the file if it already exists. Defaults to False.

False

maxar_items(collection_id, child_id, return_gdf=True, assets=['visual'], **kwargs)

Retrieve STAC items from Maxar's public STAC API.

Parameters:

Name Type Description Default
collection_id str

The collection ID, e.g., Kahramanmaras-turkey-earthquake-23 Use maxar_collections() to retrieve all available collection IDs.

required
child_id str

The child collection ID, e.g., 1050050044DE7E00 Use maxar_child_collections() to retrieve all available child collection IDs.

required
return_gdf bool

If True, return a GeoDataFrame. Defaults to True.

True
assets list

A list of asset names to include in the GeoDataFrame. It can be "visual", "ms_analytic", "pan_analytic", "data-mask". Defaults to ['visual'].

['visual']
**kwargs Any

Additional keyword arguments to pass to the pystac Catalog.from_file() method.

{}

Returns:

Type Description
Union[GeoDataFrame, List[Dict[str, Any]]]

If return_gdf is True, return a GeoDataFrame.

maxar_refresh()

Refresh the cached Maxar STAC items.

Search Maxar Open Data by collection ID, date range, and/or bounding box.

Parameters:

Name Type Description Default
collection str

The collection ID, e.g., Kahramanmaras-turkey-earthquake-23. Use maxar_collections() to retrieve all available collection IDs.

required
start_date str

The start date, e.g., 2023-01-01. Defaults to None.

None
end_date str

The end date, e.g., 2023-12-31. Defaults to None.

None
bbox list | GeoDataFrame

The bounding box to filter by. Can be a list of 4 coordinates or a file path or a GeoDataFrame.

None
within bool

Whether to filter by the bounding box or the bounding box's interior. Defaults to False.

False
align bool

If True, automatically aligns GeoSeries based on their indices. If False, the order of elements is preserved.

True

Returns:

Type Description
GeoDataFrame

A GeoDataFrame containing the search results.

maxar_tile_url(collection, tile, dtype='geojson', raw=True)

Retrieve the URL to a Maxar Open Data tile.

Args:

1
2
3
4
5
collection (str): The collection ID, e.g., Kahramanmaras-turkey-earthquake-23.
    Use maxar_collections() to retrieve all available collection IDs.
tile (str): The tile ID, e.g., 10300500D9F8E600.
dtype (str, optional): The data type. It can be 'geojson', 'json' or 'tsv'. Defaults to 'geojson'.
raw (bool, optional): If True, return the raw URL. Defaults to True.

Returns:

Type Description
str

The URL to the tile.

Search OpenAerialMap (https://openaerialmap.org) and return a GeoDataFrame or list of image metadata.

Parameters:

Name Type Description Default
bbox list | str

The bounding box [xmin, ymin, xmax, ymax] to search within. Defaults to None.

None
start_date str

The start date to search within, such as "2015-04-20T00:00:00.000Z". Defaults to None.

None
end_date str

The end date to search within, such as "2015-04-21T00:00:00.000Z". Defaults to None.

None
limit int

The maximum number of results to return. Defaults to 100.

100
return_gdf bool

If True, return a GeoDataFrame, otherwise return a list. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the API. See https://hotosm.github.io/oam-api/

{}

Returns:

Type Description
Union[GeoDataFrame, List[Dict[str, Any]]]

If return_gdf is True, return a GeoDataFrame. Otherwise, return a list.

run_titiler(show_logs=False, start_port=8000, max_port=8100, return_titiler_endpoint=False)

Run TiTiler as a background service on an available port.

This function automatically detects Google Colab and adjusts the endpoint URL to use localhost remapping (https://localhost:{port}) for compatibility.

Parameters:

Name Type Description Default
show_logs bool

If True, stream logs to the notebook output.

False
start_port int

First port to try.

8000
max_port int

Last port to try (exclusive).

8100
return_titiler_endpoint bool

If True, return the titiler endpoint. Defaults to False.

False

Returns:

Name Type Description
tuple

(endpoint, port, process)

run_titiler_xarray(show_logs=False, start_port=8000, max_port=8100)

Start a local titiler-xarray server for Zarr/NetCDF visualization.

This function starts a local titiler-xarray server that enables dynamic tile serving from Zarr and NetCDF datasets. The server runs in the background and will be automatically stopped when the Python kernel is terminated.

Requirements
  • titiler.xarray package: pip install "titiler.xarray[full]"
  • uvicorn: pip install uvicorn

Parameters:

Name Type Description Default
show_logs bool

If True, stream server logs to notebook output. Defaults to False.

False
start_port int

First port to try. Defaults to 8000.

8000
max_port int

Last port to try (exclusive). Defaults to 8100.

8100

Returns:

Name Type Description
str str

The endpoint URL of the running titiler-xarray server.

Example

endpoint = leafmap.run_titiler_xarray() m = leafmap.Map() m.add_zarr(url, variable="temperature", titiler_endpoint=endpoint)

stac_assets(url=None, collection=None, item=None, titiler_endpoint=None, **kwargs)

Get all assets of a STAC item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A list of assets.

stac_bands(url=None, collection=None, item=None, titiler_endpoint=None, **kwargs)

Get band names of a single SpatialTemporal Asset Catalog (STAC) item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A list of band names

stac_bounds(url=None, collection=None, item=None, titiler_endpoint=None, **kwargs)

Get the bounding box of a single SpatialTemporal Asset Catalog (STAC) item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A list of values representing [left, bottom, right, top]

stac_center(url=None, collection=None, item=None, titiler_endpoint=None, **kwargs)

Get the centroid of a single SpatialTemporal Asset Catalog (STAC) item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
tuple Tuple[float, float]

A tuple representing (longitude, latitude)

stac_client(url, headers=None, parameters=None, ignore_conformance=False, modifier=None, request_modifier=None, stac_io=None, return_col_id=False, get_root=True, **kwargs)

Get the STAC client. It wraps the pystac.Client.open() method. See https://pystac-client.readthedocs.io/en/stable/api.html#pystac_client.Client.open

Parameters:

Name Type Description Default
url str

The URL of a STAC Catalog.

required
headers dict

A dictionary of additional headers to use in all requests made to any part of this Catalog/API. Defaults to None.

None
parameters dict

Optional dictionary of query string parameters to include in all requests. Defaults to None.

None
ignore_conformance bool

Ignore any advertised Conformance Classes in this Catalog/API. This means that functions will skip checking conformance, and may throw an unknown error if that feature is not supported, rather than a NotImplementedError. Defaults to False.

False
modifier function

A callable that modifies the children collection and items returned by this Client. This can be useful for injecting authentication parameters into child assets to access data from non-public sources. Defaults to None.

None
request_modifier function

A callable that either modifies a Request instance or returns a new one. This can be useful for injecting Authentication headers and/or signing fully-formed requests (e.g. signing requests using AWS SigV4). The callable should expect a single argument, which will be an instance of requests.Request. If the callable returns a requests.Request, that will be used. Alternately, the callable may simply modify the provided request object and return None.

None
stac_io stac_io

A StacApiIO object to use for I/O requests. Generally, leave this to the default. However in cases where customized I/O processing is required, a custom instance can be provided here.

None
return_col_id bool

Return the collection ID. Defaults to False.

False
get_root bool

Get the root link of the STAC object. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the pystac.Client.open() method.

{}

Returns:

Type Description
Any

The STAC client.

stac_collections(url, return_ids=False, get_root=True, **kwargs)

Get the collection IDs of a STAC catalog.

Parameters:

Name Type Description Default
url str

The STAC catalog URL.

required
return_ids bool

Return collection IDs. Defaults to False.

False
get_root bool

Get the root link of the STAC object. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the stac_client() method.

{}

Returns:

Type Description
List

A list of collection IDs.

stac_info(url=None, collection=None, item=None, assets=None, titiler_endpoint=None, **kwargs)

Get band info of a STAC item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A dictionary of band info.

stac_info_geojson(url=None, collection=None, item=None, assets=None, titiler_endpoint=None, **kwargs)

Get band info of a STAC item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A dictionary of band info.

stac_min_max(url=None, collection=None, item=None, assets=None, titiler_endpoint=None, **kwargs)

Get the min and max values of a STAC item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A dictionary of band statistics.

stac_object_type(url, **kwargs)

Get the STAC object type.

Parameters:

Name Type Description Default
url str

The STAC object URL.

required
**kwargs Any

Keyword arguments for pystac.STACObject.from_file(). Defaults to None.

{}

Returns:

Type Description
str

The STAC object type, can be catalog, collection, or item.

stac_pixel_value(lon, lat, url=None, collection=None, item=None, assets=None, titiler_endpoint=None, verbose=True, **kwargs)

Get pixel value from STAC assets.

Parameters:

Name Type Description Default
lon float

Longitude of the pixel.

required
lat float

Latitude of the pixel.

required
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None
verbose bool

Print out the error message. Defaults to True.

True

Returns:

Type Description
Dict[str, Any]

A dictionary of pixel values for each asset.

Get the root link of a STAC object.

Parameters:

Name Type Description Default
url str

The STAC object URL.

required
return_col_id bool

Return the collection ID if the STAC object is a collection. Defaults to False.

False
**kwargs Any

Keyword arguments for pystac.STACObject.from_file().

{}

Returns:

Type Description
str

The root link of the STAC object. Returns None if no root link found.

str

If return_col_id is True, returns (root_link, collection_id).

Raises:

Type Description
ValueError

If FeatureCollection contains no features.

Search a STAC API. The function wraps the pysatc_client.Client.search() method. See https://pystac-client.readthedocs.io/en/stable/api.html#pystac_client.Client.search

Parameters:

Name Type Description Default
url str

The STAC API URL.

required
method str

The HTTP method to use when making a request to the service. This must be either "GET", "POST", or None. If None, this will default to "POST". If a "POST" request receives a 405 status for the response, it will automatically retry with "GET" for all subsequent requests. Defaults to "POST".

'POST'
max_items init

The maximum number of items to return from the search, even if there are more matching results. This client to limit the total number of Items returned from the items(), item_collections(), and items_as_dicts methods(). The client will continue to request pages of items until the number of max items is reached. This parameter defaults to 100. Setting this to None will allow iteration over a possibly very large number of results.. Defaults to None.

None
limit int

A recommendation to the service as to the number of items to return per page of results. Defaults to 100.

100
ids list

List of one or more Item ids to filter on. Defaults to None.

None
collections list

List of one or more Collection IDs or pystac.Collection instances. Only Items in one of the provided Collections will be searched. Defaults to None.

None
bbox list | tuple

A list, tuple, or iterator representing a bounding box of 2D or 3D coordinates. Results will be filtered to only those intersecting the bounding box. Defaults to None.

None
intersects str | dict

A string or dictionary representing a GeoJSON geometry, or an object that implements a geo_interface property, as supported by several libraries including Shapely, ArcPy, PySAL, and geojson. Results filtered to only those intersecting the geometry. Defaults to None.

None
datetime str

Either a single datetime or datetime range used to filter results. You may express a single datetime using a datetime.datetime instance, a RFC 3339-compliant timestamp, or a simple date string (see below). Instances of datetime.datetime may be either timezone aware or unaware. Timezone aware instances will be converted to a UTC timestamp before being passed to the endpoint. Timezone unaware instances are assumed to represent UTC timestamps. You may represent a datetime range using a "/" separated string as described in the spec, or a list, tuple, or iterator of 2 timestamps or datetime instances. For open-ended ranges, use either ".." ('2020-01-01:00:00:00Z/..', ['2020-01-01:00:00:00Z', '..']) or a value of None (['2020-01-01:00:00:00Z', None]). If using a simple date string, the datetime can be specified in YYYY-mm-dd format, optionally truncating to YYYY-mm or just YYYY. Simple date strings will be expanded to include the entire time period. Defaults to None.

None
query list

List or JSON of query parameters as per the STAC API query extension. such as {"eo:cloud_cover":{"lt":10}}. Defaults to None.

None
filter dict

JSON of query parameters as per the STAC API filter extension. Defaults to None.

None
filter_lang str

Language variant used in the filter body. If filter is a dictionary or not provided, defaults to ‘cql2-json’. If filter is a string, defaults to cql2-text. Defaults to None.

None
sortby str | list

A single field or list of fields to sort the response by. such as [{ 'field': 'properties.eo:cloud_cover', 'direction': 'asc' }]. Defaults to None.

None
fields list

A list of fields to include in the response. Note this may result in invalid STAC objects, as they may not have required fields. Use items_as_dicts to avoid object unmarshalling errors. Defaults to None.

None
get_collection bool

True to return a pystac.ItemCollection. Defaults to False.

False
get_items bool

True to return a list of pystac.Item. Defaults to False.

False
get_assets bool

True to return a list of pystac.Asset. Defaults to False.

False
get_links bool

True to return a list of links. Defaults to False.

False
get_gdf bool

True to return a GeoDataFrame. Defaults to False.

False
get_info bool

True to return a dictionary of STAC items. Defaults to False.

False
get_root bool

Get the root link of the STAC object. Defaults to True.

True
**kwargs Any

Additional keyword arguments to pass to the stac_client() function.

{}

Returns:

Type Description
List

The search results as a list of links or a pystac.ItemCollection.

stac_search_to_df(search, **kwargs)

Convert STAC search result to a DataFrame.

Parameters:

Name Type Description Default
search item_search

The search result returned by leafmap.stac_search().

required
**kwargs Any

Additional keyword arguments to pass to the DataFrame.drop() function.

{}

Returns:

Type Description
DataFrame

A Pandas DataFrame object.

stac_search_to_dict(search, **kwargs)

Convert STAC search result to a dictionary.

Parameters:

Name Type Description Default
search item_search

The search result returned by leafmap.stac_search().

required

Returns:

Name Type Description
dict Dict

A dictionary of STAC items, with the stac item id as the key, and the stac item as the value.

stac_search_to_gdf(search, **kwargs)

Convert STAC search result to a GeoDataFrame.

Parameters:

Name Type Description Default
search item_search

The search result returned by leafmap.stac_search().

required
**kwargs Any

Additional keyword arguments to pass to the GeoDataFrame.from_features() function.

{}

Returns:

Type Description
GeoDataFrame

A GeoPandas GeoDataFrame object.

stac_search_to_list(search, **kwargs)

Convert STAC search result to a list.

Parameters:

Name Type Description Default
search item_search

The search result returned by leafmap.stac_search().

required

Returns:

Name Type Description
list List

A list of STAC items.

stac_stats(url=None, collection=None, item=None, assets=None, titiler_endpoint=None, **kwargs)

Get band statistics of a STAC item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None.

None

Returns:

Name Type Description
list List

A dictionary of band statistics.

stac_tile(url=None, collection=None, item=None, assets=None, bands=None, titiler_endpoint=None, **kwargs)

Get a tile layer from a single SpatialTemporal Asset Catalog (STAC) item.

Parameters:

Name Type Description Default
url str

HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json

None
collection str

The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2.

None
item str

The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1.

None
assets str | list

The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"].

None
bands list

A list of band names, e.g., ["SR_B7", "SR_B5", "SR_B4"]

None
titiler_endpoint str

TiTiler endpoint, e.g., "https://titiler.opengeos.org", "https://planetarycomputer.microsoft.com/api/data/v1", "planetary-computer", "pc". Defaults to None.

None

Returns:

Type Description
str

The STAC tile layer URL.

zarr_bounds(url, variable=None, titiler_endpoint=None, group=None, decode_times=False, **kwargs)

Get the bounds of a Zarr dataset.

Parameters:

Name Type Description Default
url str

HTTP URL to a Zarr dataset.

required
variable str

The variable name. Defaults to None.

None
titiler_endpoint str

TiTiler endpoint that supports xarray/Zarr. If not provided, the function first checks the TITILER_XARRAY_ENDPOINT environment variable; if that is not set, it falls back to the default endpoint returned by :func:check_titiler_endpoint.

None
group str

The Zarr group path within the dataset. Defaults to None.

None
decode_times bool

Whether to decode times in the dataset. Defaults to False.

False
**kwargs

Additional arguments to pass to the titiler endpoint.

{}

Returns:

Name Type Description
list list

Bounds as [minx, miny, maxx, maxy] in WGS84.

zarr_info(url, variable=None, titiler_endpoint=None, group=None, decode_times=False, **kwargs)

Get information about a Zarr dataset.

Parameters:

Name Type Description Default
url str

HTTP URL to a Zarr dataset.

required
variable str

The variable name. Required by titiler-xarray. Defaults to None.

None
titiler_endpoint str

TiTiler endpoint that supports xarray/Zarr. Defaults to "https://titiler.opengeos.org".

None
group str

The Zarr group path within the dataset. Defaults to None.

None
decode_times bool

Whether to decode times in the dataset. Defaults to False.

False
**kwargs

Additional arguments to pass to the titiler endpoint.

{}

Returns:

Name Type Description
dict dict

Information about the Zarr dataset including bounds, CRS, and variables.

zarr_statistics(url, variable=None, titiler_endpoint=None, group=None, decode_times=False, **kwargs)

Get statistics for a Zarr dataset variable.

Parameters:

Name Type Description Default
url str

HTTP URL to a Zarr dataset.

required
variable str

The variable name. Required for multi-variable datasets.

None
titiler_endpoint str

TiTiler endpoint that supports xarray/Zarr. Defaults to "https://titiler.opengeos.org".

None
group str

The Zarr group path within the dataset. Defaults to None.

None
decode_times bool

Whether to decode times in the dataset. Defaults to False.

False
**kwargs

Additional arguments to pass to the titiler endpoint.

{}

Returns:

Name Type Description
dict dict

Statistics including min, max, mean, std, etc.

zarr_tile(url, variable=None, titiler_endpoint=None, group=None, decode_times=False, time_index=0, **kwargs)

Get a tile layer URL from a Zarr dataset using titiler-xarray.

This function requires a TiTiler endpoint with titiler-xarray support. The default titiler endpoint does NOT support Zarr/xarray datasets. You need to either: 1. Set up your own titiler-xarray endpoint 2. Use leafmap.run_titiler_xarray() to start a local server

Parameters:

Name Type Description Default
url str

HTTP URL to a Zarr dataset, e.g., https://example.com/data.zarr or s3://bucket/data.zarr

required
variable str

The variable name to visualize. Required for multi-variable datasets. Defaults to None.

None
titiler_endpoint str

TiTiler endpoint that supports xarray/Zarr. Must have titiler-xarray installed. Defaults to environment variable TITILER_XARRAY_ENDPOINT or prompts user to start a local server.

None
group str

The Zarr group path within the dataset. Defaults to None.

None
decode_times bool

Whether to decode times in the dataset. Defaults to False.

False
time_index int

Index of the time dimension to visualize. Required for datasets with a time dimension. Defaults to 0 (first time step). Set to None to disable time selection (for datasets without time dimension).

0
**kwargs Any

Additional arguments to pass to the titiler endpoint. Common options include: - rescale (str): Comma-delimited Min,Max range (e.g., "0,255") - colormap_name (str): Name of a colormap (e.g., "viridis") - colormap (str): JSON encoded custom colormap - nodata (float): Nodata value - sel (str): Dimension selection in format "dim=value" (e.g., "time=0") - TileMatrixSetId (str): Tile matrix set ID (default: "WebMercatorQuad")

{}

Returns:

Name Type Description
str str

The Zarr tile layer URL, or None if the endpoint doesn't support Zarr.

Example

Start local titiler-xarray server first

endpoint = leafmap.run_titiler_xarray() url = "https://example.com/data.zarr" tile_url = zarr_tile(url, variable="temperature", titiler_endpoint=endpoint)

zarr_variables(url, titiler_endpoint=None, group=None, decode_times=False, **kwargs)

Get the list of variables from a Zarr dataset.

Parameters:

Name Type Description Default
url str

HTTP URL to a Zarr dataset.

required
titiler_endpoint str

TiTiler endpoint that supports xarray/Zarr. Defaults to "https://titiler.opengeos.org".

None
group str

The Zarr group path within the dataset. Defaults to None.

None
decode_times bool

Whether to decode times in the dataset. Defaults to False.

False
**kwargs

Additional arguments to pass to the titiler endpoint.

{}

Returns:

Name Type Description
list list

List of variable names in the Zarr dataset.