Using local raster datasets or remote Cloud Optimized GeoTIFFs (COG) with leafmap
Uncomment the following line to install leafmap and localtileserver if needed.
# !pip install leafmap
# !pip install localtileserver
import leafmap
Specify input raster datasets
dem = "dem.tif"
landsat = "landsat.tif"
Download samples raster datasets.
dem_url = (
"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, dem, unzip=False)
landsat_url = "https://github.com/opengeos/leafmap/raw/master/examples/data/cog.tif"
leafmap.download_file(landsat_url, landsat, unzip=False)
Create an interactive map.
m = leafmap.Map()
Add local raster datasets to the map. The available palettes can be found at https://jiffyclub.github.io/palettable/
m.add_raster(landsat, indexes=[4, 3, 2], layer_name="Landsat")
m.add_raster(dem, colormap="viridis", layer_name="DEM")
m
Add a remote Cloud Optimized GeoTIFF(COG) to the map.
m = leafmap.Map()
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif"
m.add_cog_layer(url, name="Maxar")
m