113 titiler cmr
Visualizing NASA Earthdata with TiTiler CMR
This notebook demonstrates how to visualize NASA Earthdata collections on interactive maps using leafmap and the TiTiler CMR endpoint.
TiTiler CMR provides dynamic tiling services for NASA's Common Metadata Repository (CMR) collections, allowing you to visualize large-scale Earth science datasets directly on web maps without downloading the data.
Key Features: - Access NASA Earthdata collections using concept IDs - Support for both rasterio (COGs) and xarray (NetCDF/Zarr) backends - Dynamic rescaling and colormap application - Time series visualization with interactive sliders - Band math expressions for derived products (e.g., NDVI)
References: - TiTiler CMR GitHub - NASA Earthdata CMR - NASA Earthdata Search
Installation¶
Uncomment the following line to install leafmap if needed.
1 | |
1 | |
Understanding NASA CMR Concept IDs¶
Each NASA Earthdata collection has a unique Concept ID. You can find concept IDs by:
- Searching on NASA Earthdata Search
- Using the CMR API
Common concept IDs used in this notebook:
| Dataset | Concept ID | Backend | Description |
|---|---|---|---|
| MUR SST | C2036881735-POCLOUD | xarray | Sea Surface Temperature |
| HLS Landsat | C2021957657-LPCLOUD | rasterio | Harmonized Landsat Sentinel-2 |
| HLS Sentinel-2 | C2021957295-LPCLOUD | rasterio | Harmonized Landsat Sentinel-2 |
Example 1: Sea Surface Temperature (xarray backend)¶
The MUR Sea Surface Temperature dataset uses the xarray backend because it's stored as NetCDF/Zarr format. We need to specify the variable parameter for xarray datasets.
1 2 3 4 5 6 7 8 9 10 11 | |
Example 2: HLS Landsat True Color (rasterio backend)¶
The Harmonized Landsat Sentinel-2 (HLS) dataset uses the rasterio backend because it's stored as Cloud Optimized GeoTIFFs (COGs). We can specify bands for RGB visualization.
1 2 3 4 5 6 7 8 9 10 11 12 | |
Example 3: NDVI with Band Math Expression¶
You can use band math expressions to create derived products like NDVI (Normalized Difference Vegetation Index).
1 2 3 4 5 6 7 8 9 10 11 12 | |
1 | |
Example 4: Sea Ice Fraction Time Series¶
The add_cmr_timeseries method creates an interactive time slider for temporal datasets. This is useful for visualizing changes over time.
1 2 3 4 5 6 7 8 9 10 11 12 | |
Using the Low-Level API Functions¶
Leafmap also provides low-level functions for more control over the CMR tile requests.
Get TileJSON Metadata¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Get Bounds and Center¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Using with Folium Backend¶
The add_cmr_layer method is also available in the Folium backend.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Using with MapLibre Backend¶
The add_cmr_layer method is also available in the MapLibre backend.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Common NASA Earthdata Collections¶
Here are some commonly used NASA Earthdata collections:
Sea Surface Temperature (MUR SST)¶
- Concept ID: C2036881735-POCLOUD
- Backend: xarray
- Variables: analysed_sst, analysis_error, mask, sea_ice_fraction
- Rescale: 270,305 (Kelvin)
Harmonized Landsat Sentinel-2 (HLS)¶
- Landsat Concept ID: C2021957657-LPCLOUD
- Sentinel-2 Concept ID: C2021957295-LPCLOUD
- Backend: rasterio
- Bands: B01-B12, Fmask
- Common band combinations:
- True Color: B04, B03, B02
- False Color: B05, B04, B03
- NDVI: (B05-B04)/(B05+B04)
ISO 8601 Duration Codes for Time Steps¶
- P1D: 1 day
- P1W: 1 week
- P2W: 2 weeks
- P1M: 1 month
- P1Y: 1 year
Summary¶
Key functions for visualizing NASA Earthdata with TiTiler CMR:
Map Methods:
- map.add_cmr_layer() - Add a single CMR layer to the map
- map.add_cmr_timeseries() - Add a time series with interactive slider (ipyleaflet only)
Low-Level Functions:
- leafmap.stac.cmr_tilejson() - Get TileJSON metadata
- leafmap.stac.cmr_tile() - Get tile URL template
- leafmap.stac.cmr_bounds() - Get geographic bounds
- leafmap.stac.cmr_center() - Get center coordinates
- leafmap.stac.cmr_timeseries_tilejson() - Get time series TileJSON
- leafmap.stac.cmr_animated_gif() - Generate animated GIF
- leafmap.stac.cmr_statistics() - Calculate statistics for an AOI
Key Parameters:
- concept_id - NASA CMR collection ID
- datetime - Date or date range (RFC3339 format)
- backend - 'rasterio' for COGs, 'xarray' for NetCDF/Zarr
- variable - Variable name (required for xarray backend)
- bands - Band names for rasterio backend
- expression - Band math expression
- rescale - Min/max values for rescaling
- colormap_name - Colormap name (e.g., 'thermal', 'viridis')