aperta.topography

Topographic data fetchers for aperta.

So far one helper: fetch_copernicus_dem, which downloads, mosaics, clips, and (optionally) reprojects Copernicus GLO-30 DEM tiles from AWS Open Data for a given polygon. The Copernicus GLO-30 is the de facto open global 30 m DEM and is the right default for accessibility analyses that need elevation-aware edge weights.

Heavy optional dependencies (rasterio, requests) are imported lazily — the rest of aperta works without them.

aperta.topography.fetch_copernicus_dem(polygon, out_path, *, polygon_crs='EPSG:4326', target_crs=None, cache_tile_dir=None, cleanup_tiles=True, verbose=True)[source]

Download + mosaic + clip + reproject Copernicus GLO-30 DEM for a polygon.

Workflow:

  1. Compute the 1° × 1° tile bounding box covering polygon in EPSG:4326.

  2. Download each tile from AWS Open Data (skipped if already present in cache_tile_dir).

  3. Mosaic the tiles with rasterio.merge.

  4. Clip to polygon (in EPSG:4326).

  5. Optionally reproject to target_crs.

  6. Write the result as a compressed GeoTIFF to out_path.

  7. Optionally clean up the raw tile files.

If out_path already exists, the function is a no-op and returns out_path immediately — caller is responsible for invalidating the cache (e.g., delete the file) when the underlying request changes.

Parameters:
  • polygon – shapely Polygon or MultiPolygon covering the area of interest.

  • out_path – destination GeoTIFF path. Parent directory must exist.

  • polygon_crs (str) – CRS of polygon (default ‘EPSG:4326’).

  • target_crs (str | None) – CRS of the output GeoTIFF (e.g. ‘EPSG:2056’ for Swiss LV95). None keeps EPSG:4326.

  • cache_tile_dir – directory for downloaded raw tiles. None defaults to the parent of out_path. Tiles already present here are not re-downloaded.

  • cleanup_tiles (bool) – if True (default), the raw per-tile .tif files are deleted after the mosaic / clip / reproject; set False to keep them for reuse.

  • verbose (bool) – print per-tile download progress + final summary.

Returns:

Path to the saved GeoTIFF (same as out_path).

Raises:
  • ImportError – if rasterio or requests is not installed.

  • requests.HTTPError – on tile-download failure.

Return type:

Path