mirrorworld.elevation: Elevation models

Elevation for a bounding box (Netherlands, England, Wales, United States, worldwide) as mirrorworld.raster.Raster objects in meters. Needs pip install mirrorworld[raster].

AHN (Netherlands, 0.5 m)

get_dsm(north, west, south, east)[source]

Downloads the digital surface model (top of buildings, trees, poles, …) for a bounding box.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters above NAP; water and gaps are nodata.

Return type:

Raster

async get_dsm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

get_dtm(north, west, south, east)[source]

Downloads the digital terrain model (bare ground) for a bounding box.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters above NAP; buildings and water are nodata.

Return type:

Raster

async get_dtm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

get_ndsm(north, west, south, east)[source]

Computes object heights above ground (surface model minus terrain model), e.g. for pole, tree and building heights. Where the terrain model has gaps (under buildings), the lowest terrain height in the box is used.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster of heights above ground in meters.

Return type:

Raster

async get_ndsm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

download_dsm(north, west, south, east, path)[source]

Same as get_dsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_dtm(north, west, south, east, path)[source]

Same as get_dtm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_ndsm(north, west, south, east, path)[source]

Same as get_ndsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

compute_ndsm(dsm, dtm)[source]

Subtracts a terrain model from a surface model on the same grid.

Parameters:
Return type:

Raster

Usage sample:

from mirrorworld.elevation import ahn

heights = ahn.get_ndsm(52.3736, 4.8915, 52.3728, 4.8932)   # object heights above ground
heights.save("ndsm.tif")

Environment Agency (England, 1 m)

get_dtm(north, west, south, east)[source]

Downloads the 1 m terrain model (bare ground) for a bounding box in England.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters above Ordnance Datum Newlyn (EPSG:27700).

Raises:

ValueError – If the box is outside the coverage.

Return type:

Raster

async get_dtm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

get_dsm(north, west, south, east)[source]

Downloads the 1 m first-return surface model (top of buildings, trees, poles, wires) for a bounding box in England.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters above Ordnance Datum Newlyn (EPSG:27700).

Raises:

ValueError – If the box is outside the coverage.

Return type:

Raster

async get_dsm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

get_ndsm(north, west, south, east)[source]

Computes object heights above ground (first-return DSM minus DTM), e.g. for tree, building and pole heights.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster of heights above ground in meters.

Return type:

Raster

async get_ndsm_async(north, west, south, east, session)[source]
Parameters:
Return type:

Raster

download_dtm(north, west, south, east, path)[source]

Same as get_dtm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_dsm(north, west, south, east, path)[source]

Same as get_dsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_ndsm(north, west, south, east, path)[source]

Same as get_ndsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

Usage sample:

from mirrorworld.elevation import ea

heights = ea.get_ndsm(51.50785, -0.1287, 51.50695, -0.1269)   # object heights, Charing Cross
heights.save("ndsm.tif")

Wales (1 m)

get_dsm(north, west, south, east)[source]

Reads the 1 m surface model (top of buildings, trees, …) for a bounding box in Wales.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters (EPSG:27700).

Raises:

ValueError – If the box has no Welsh LiDAR data.

Return type:

Raster

get_dtm(north, west, south, east)[source]

Reads the 1 m terrain model (bare ground) for a bounding box in Wales.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

Returns:

A float32 raster in meters (EPSG:27700).

Raises:

ValueError – If the box has no Welsh LiDAR data.

Return type:

Raster

get_ndsm(north, west, south, east)[source]

Computes object heights above ground (DSM minus DTM) for a bounding box in Wales.

Returns:

A float32 raster of heights above ground in meters.

Parameters:
Return type:

Raster

download_dsm(north, west, south, east, path)[source]

Same as get_dsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_dtm(north, west, south, east, path)[source]

Same as get_dtm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

download_ndsm(north, west, south, east, path)[source]

Same as get_ndsm(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

Usage sample:

from mirrorworld.elevation import wales

wales.download_dsm(51.4820, -3.1830, 51.4800, -3.1780, "cardiff_dsm.tif")

USGS 3DEP (United States, bare earth)

get_dem(north, west, south, east, resolution=1.0, crs=None, max_size=2000)[source]

Downloads the bare-earth elevation model for a bounding box.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

  • resolution (float) – (optional) Pixel size in meters. Defaults to 1.

  • crs (str | None) – (optional) Output CRS. Defaults to the UTM zone of the box center.

  • max_size (int) – (optional) Largest chunk side in pixels. Defaults to 2000.

Returns:

A float32 raster of elevations in meters (NAVD88).

Raises:

ValueError – If there is no 3DEP data in the box.

Return type:

Raster

async get_dem_async(north, west, south, east, session, resolution=1.0, crs=None, max_size=2000)[source]
Parameters:
Return type:

Raster

download_dem(north, west, south, east, path, **kwargs)[source]

Same as get_dem(), then saves the result (use .tif to keep the values).

Parameters:
Return type:

Raster

Usage sample:

from mirrorworld.elevation import usgs3dep

usgs3dep.download_dem(47.6068, -122.3340, 47.6058, -122.3325, "dem.tif", resolution=1.0)

Copernicus DEM (worldwide, 30 m surface model)

find_scenes(north, west, south, east, start=None, end=None, limit=50)[source]

Finds Copernicus DEM tiles intersecting a bounding box, newest first.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

  • start (str | datetime | None) – (optional) Earliest acquisition date, e.g. "2024-06-01".

  • end (str | datetime | None) – (optional) Latest acquisition date (inclusive).

  • limit (int) – (optional) Maximum number of scenes. Defaults to 50.

Returns:

A list of Scene objects.

Return type:

List[Scene]

async find_scenes_async(north, west, south, east, session, start=None, end=None, limit=50)[source]
Parameters:
Return type:

List[Scene]

get_raster(north, west, south, east, scenes=None, bands=('data',), resolution=None, crs=None, start=None, end=None, resampling='bilinear')[source]

Reads Copernicus DEM elevations for a bounding box.

Parameters:
  • north (float) – Latitude of the top edge.

  • west (float) – Longitude of the left edge.

  • south (float) – Latitude of the bottom edge.

  • east (float) – Longitude of the right edge.

  • scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from find_scenes(). Defaults to the newest acquisition covering the box within start/end.

  • bands (Sequence[str]) – (optional) Asset names; data holds the heights. Defaults to ("data",).

  • resolution (float | None) – (optional) Pixel size in meters. Defaults to the native resolution (1 arc-second, EPSG:4326).

  • crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (EPSG:4326).

  • start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.

  • end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.

  • resampling (str) – (optional) Resampling method. Defaults to bilinear.

Returns:

A Raster; metadata names the scenes and any scale/offset per band.

Return type:

Raster

download_raster(north, west, south, east, path, **kwargs)[source]

Same as get_raster(), then saves the result (.tif keeps all bands and values).

Parameters:
Returns:

The raster.

Return type:

Raster

Usage sample:

from mirrorworld.elevation import copernicus

copernicus.download_raster(47.615, -122.345, 47.600, -122.325, "cop30.tif")