Skip to content

Terrain

Contours

Contour lines traced from open elevation tiles, generalised like a printed map, returned as a GeoDataFrame.

marra = kh.contours((24.0, 12.75, 24.5, 13.15), interval=100)

Needs pip install kharita[terrain]. where is a GeoDataFrame, a GeoSeries or a (west, south, east, north) box.

Argument Does
interval metres between lines; chosen for about 20 lines when not set
index_every every Nth line is an index contour (default 5)
detail "low", "medium" (default) or "high": how many small bumps and wiggles are kept
smooth the blur in metres, instead of detail; 0 gives raw lines
zoom tile zoom; the most detailed that needs at most 16 tiles when not set
below_sea also trace levels below zero

The result has elevation, index (True for index contours) and weight (2 for index lines, 1 for the rest), and records interval, zoom, smooth and detail in .attrs.

A topographic map

preset-topo draws brown lines with index contours twice as thick; a second layer labels the index lines.

m = kh.Map(title="Jebel Marra", subtitle="Contours every 100 m")
m.add(marra, "preset-topo basemap-topo parks-none")
m.add(index, "stroke-transparent label-[elevation] legend-none")
m

Over imagery

kh.map(marra, "basemap-hybrid stroke-amber-200/90 width-[weight] width-max-1.6 legend-none")

How detail works

Contours are generalised before they are drawn. The elevation is blurred over at least 300 m, or about a three-hundredth of the area's width, whichever is bigger (low blurs twice as much, high half as much). Then lines shorter than eight blur widths are dropped, and the rest are simplified and their corners rounded. Elevation comes from the Mapzen Terrain Tiles on AWS Open Data.