Uncomment the following line to install leafmap if needed.
# !pip install leafmap
import leafmap
Provide a dataset path or URL.
url = "https://opengeos.org/data/raster/srtm90.tif"
Validate COG.
leafmap.cog_validate(url)
leafmap.cog_validate(url, verbose=True)
Convert the image to tiled COG.
out_cog = "cog.tif"
leafmap.image_to_cog(url, out_cog)
Validate COG.
leafmap.cog_validate(out_cog)
leafmap.cog_validate(out_cog, verbose=True)
Add COG to map.
m = leafmap.Map()
m.add_raster(out_cog, palette="terrain", layer_name="Local COG")
m.add_cog_layer(url, palette="gist_earth", name="Remote COG")
m