Visualize Cloud Optimized GeoTIFF (COG)
This notebook demonstrates how to visualize Cloud Optimized GeoTIFF (COG) files using the TiTiler demo endpoint (titiler.xyz). Please be gentle with the demo endpoint.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
In [4]:
Copied!
m = leafmap.Map(style="satellite")
before = (
"https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-07-01.tif"
)
after = (
"https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-09-13.tif"
)
m.add_cog_layer(before, name="Before", attribution="Maxar")
m.add_cog_layer(after, name="After", attribution="Maxar", fit_bounds=True)
m
m = leafmap.Map(style="satellite")
before = (
"https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-07-01.tif"
)
after = (
"https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-09-13.tif"
)
m.add_cog_layer(before, name="Before", attribution="Maxar")
m.add_cog_layer(after, name="After", attribution="Maxar", fit_bounds=True)
m
Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style.
In [5]:
Copied!
m.layer_interact()
m.layer_interact()
In [6]:
Copied!
m = leafmap.Map(style="satellite")
dem = "https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif"
m.add_cog_layer(dem, name="DEM", colormap_name="terrain", fit_bounds=True)
m
m = leafmap.Map(style="satellite")
dem = "https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif"
m.add_cog_layer(dem, name="DEM", colormap_name="terrain", fit_bounds=True)
m
Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style.
In [7]:
Copied!
m.layer_interact()
m.layer_interact()