Skip to content

32 local tile

image image image

Using local raster datasets or remote Cloud Optimized GeoTIFFs (COG) with leafmap

Uncomment the following line to install leafmap and localtileserver if needed.

1
# !pip install leafmap
1
# !pip install localtileserver
1
import leafmap

Specify input raster datasets

1
2
dem = "dem.tif"
landsat = "landsat.tif"

Download samples raster datasets.

1
2
3
4
dem_url = (
    "https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, dem, unzip=False)
1
2
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.

1
m = leafmap.Map()

Add local raster datasets to the map. The available palettes can be found at https://jiffyclub.github.io/palettable/

1
m.add_raster(landsat, indexes=[4, 3, 2], layer_name="Landsat")
1
m.add_raster(dem, colormap="viridis", layer_name="DEM")
1
m

Add a remote Cloud Optimized GeoTIFF(COG) to the map.

1
m = leafmap.Map()
1
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif"
1
m.add_cog_layer(url, name="Maxar")
1
m