Skip to content

54 plot raster

image image image

Uncomment the following line to install leafmap if needed.

1
# !pip install leafmap
1
2
import os
import leafmap

Download a sample dataset.

1
url = "https://opengeos.org/data/raster/srtm90.tif"
1
2
3
image = "srtm90.tif"
if not os.path.exists(image):
    leafmap.download_file(url, image)

Plot the raster image in 2D.

1
leafmap.plot_raster(image, cmap="terrain", figsize=(15, 10))

Plot the raster image in 3D.

1
leafmap.plot_raster_3d("srtm90.tif", factor=2, cmap="terrain", background="gray")