2 · contours(filled=True)¶
Map.contours(filled=True) renders a raster as filled contours (cleopatra ArrayGlyph, kind="contourf"). Map reprojects via pyramids and draws on a shared axes; colorbar() adds one aggregated bar.
Setup — inline plots and the path to the bundled Lisbon DEM.
In [1]:
Copied!
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
from pyramids.dataset import Dataset
from digitalearth.static import Map
ds = Dataset.read_file(DEM)
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
from pyramids.dataset import Dataset
from digitalearth.static import Map
ds = Dataset.read_file(DEM)
Draw the Lisbon DEM with Map.contours(filled=True). levels= sets the class breaks.
In [2]:
Copied!
m = Map(crs=ds.epsg, figsize=(9, 7))
m.contours(ds, cmap='terrain', filled=True)
m.colorbar(label='elevation (m)')
m.set_title('contourf')
m.fig;
m = Map(crs=ds.epsg, figsize=(9, 7))
m.contours(ds, cmap='terrain', filled=True)
m.colorbar(label='elevation (m)')
m.set_title('contourf')
m.fig;