topotoolbox.load_open_topography

topotoolbox.load_open_topography#

topotoolbox.load_open_topography(south: float, north: float, west: float, east: float, api_key: str | None = None, dem_type: str = 'SRTMGL3', api_path: str | None = None, overwrite: bool = False, save_path: str | None = None) GridObject[source]#

Download a DEM from Open Topography. The DEM is downloaded as a GeoTIFF file and saved in the cache directory. The DEM is then read into a GridObject. The DEMs come in geographic coordinates (WGS84). The API key is required for accessing the OpenTopography API (opentopography.org). To avoid having to pass the API key as an argument, save it in .opentopography.txt in the working or home directory. To overwrite an existing downloaded DEM, use the overwrite parameter. To save the DEM to a different location, use the save_path parameter.

Parameters:
  • south (float) – WGS 84 bounding box south coordinates

  • north (float) – WGS 84 bounding box north coordinates

  • west (float) – WGS 84 bounding box west coordinates

  • east (float) – WGS 84 bounding box east coordinates

  • api_key (str | None) – The API key is needed to access the Open Topography API. To get an API key, visit opentopography.org, log in, navigate to MyOpenTopoDashboard and request a new API key. This argument is used to pass the API key directly as a string. By default None.

  • api_path (str | None) – The path to a file that contains the API key. If provided, the API key will be read from the file. The file should contain only the API key without any additional text or formatting. By default None.

  • dem_type (str, optional) –

    Choose one of the available global raster types, by default “SRTMGL3”

    • SRTMGL3 (SRTM GL3 90m)

    • SRTMGL1 (SRTM GL1 30m)

    • SRTMGL1_E (SRTM GL1 Ellipsoidal 30m)

    • AW3D30 (ALOS World 3D 30m)

    • AW3D30_E (ALOS World 3D Ellipsoidal, 30m)

    • SRTM15Plus (Global Bathymetry SRTM15+ V2.1 500m)

    • NASADEM (NASADEM Global DEM)

    • COP30 (Copernicus Global DSM 30m)

    • COP90 (Copernicus Global DSM 90m)

    • EU_DTM (DTM 30m)

    • GEDI_L3 (DTM 1000m)

    • GEBCOIceTopo (Global Bathymetry 500m)

    • GEBCOSubIceTopo (Global Bathymetry 500m)

  • overwrite (bool, optional) – If True cached DEM will be overwritten if it has the same bounds and dem_type, by default False

  • save_path (str | None, optional) – If provided, the downloaded GeoTIFF will be saved to this path. Like this “path/to/file.tif” for example. If it is None, files will be saved in cache. By default None

Returns:

A GridObject generated from the downloaded DEM.

Return type:

GridObject

Raises:
  • ValueError – If the provided DEM type is not valid.

  • ConnectionError – If the API request fails or returns an error.

Example

dem = topotoolbox.load_open_topography(south=50, north=50.1, west=14.35,

east=14.6, dem_type=”SRTMGL3”, api_key=”demoapikeyot2022”)

dem = dem.reproject(rasterio.CRS.from_epsg(32633), resolution=90) im = dem.plot(cmap=”terrain”) plt.show()