42 create cog
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [ ]:
Copied!
import leafmap
import leafmap
Provide a dataset path or URL.
In [ ]:
Copied!
url = "https://open.gishub.org/data/raster/srtm90.tif"
url = "https://open.gishub.org/data/raster/srtm90.tif"
Validate COG.
In [ ]:
Copied!
leafmap.cog_validate(url)
leafmap.cog_validate(url)
In [ ]:
Copied!
leafmap.cog_validate(url, verbose=True)
leafmap.cog_validate(url, verbose=True)
Convert the image to tiled COG.
In [ ]:
Copied!
out_cog = "cog.tif"
leafmap.image_to_cog(url, out_cog)
out_cog = "cog.tif"
leafmap.image_to_cog(url, out_cog)
Validate COG.
In [ ]:
Copied!
leafmap.cog_validate(out_cog)
leafmap.cog_validate(out_cog)
In [ ]:
Copied!
leafmap.cog_validate(out_cog, verbose=True)
leafmap.cog_validate(out_cog, verbose=True)
Add COG to map.
In [ ]:
Copied!
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
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