54 plot raster
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
import os
import leafmap
import os
import leafmap
Download a sample dataset.
In [3]:
Copied!
url = "https://opengeos.org/data/raster/srtm90.tif"
url = "https://opengeos.org/data/raster/srtm90.tif"
In [4]:
Copied!
image = "srtm90.tif"
if not os.path.exists(image):
leafmap.download_file(url, image)
image = "srtm90.tif"
if not os.path.exists(image):
leafmap.download_file(url, image)
Downloading... From: https://opengeos.org/data/raster/srtm90.tif To: /home/runner/work/leafmap/leafmap/docs/notebooks/srtm90.tif
0%| | 0.00/16.6M [00:00<?, ?B/s]
100%|██████████| 16.6M/16.6M [00:00<00:00, 269MB/s]
Plot the raster image in 2D.
In [5]:
Copied!
leafmap.plot_raster(image, cmap="terrain", figsize=(15, 10))
leafmap.plot_raster(image, cmap="terrain", figsize=(15, 10))

Plot the raster image in 3D.
In [6]:
Copied!
leafmap.plot_raster_3d("srtm90.tif", factor=2, cmap="terrain", background="gray")
leafmap.plot_raster_3d("srtm90.tif", factor=2, cmap="terrain", background="gray")
