elevation#

Submodules#

Attributes#

Exceptions#

ProductRetiredError

Raised when a product label retired in elevation 2.0 is requested.

Functions#

clean([cache_dir, product])

Clean up the product cache from temporary files.

clip(bounds[, output, margin, product, cache_dir, ...])

Clip the DEM to given bounds.

dataset([dataset])

Show the STAC metadata of the datasets.

distclean([cache_dir, product])

Remove the product cache entirely.

info([cache_dir, product])

Show info about the product cache.

resolve_cache_dir(cache_dir)

Return the DEM cache folder to use, as an absolute path.

seed([cache_dir, product, bounds, max_download_tiles, ...])

Seed the DEM to given bounds.

selfcheck([tools, verbose])

Audit the system for issues.

Package Contents#

exception elevation.ProductRetiredError#

Bases: KeyError

Raised when a product label retired in elevation 2.0 is requested.

Subclasses KeyError, like an unknown product label, but renders the migration message without the repr quoting that KeyError adds.

elevation.clean(cache_dir=None, product=DEFAULT_PRODUCT)#

Clean up the product cache from temporary files.

Parameters:
  • cache_dir – Root of the DEM cache folder.

  • product – DEM product choice.

elevation.clip(bounds, output=DEFAULT_OUTPUT, margin=MARGIN, product=DEFAULT_PRODUCT, *, cache_dir=None, gdal_options=DEFAULT_GDAL_OPTIONS, max_download_tiles=MAX_DOWNLOAD_TILES)#

Clip the DEM to given bounds.

Parameters:
  • bounds – Output bounds in ‘left bottom right top’ order.

  • output – Path to output file. Existing files will be overwritten.

  • margin – Decimal degree margin added to the bounds. Use ‘%’ for percent margin.

  • product – DEM product choice.

  • cache_dir – Root of the DEM cache folder.

  • gdal_options – GDAL creation options of the output file, e.g. ‘-co COMPRESS=LZW’.

  • max_download_tiles – Maximum number of tiles to download.

elevation.dataset(dataset=None)#

Show the STAC metadata of the datasets.

Parameters:

dataset – Dataset choice, all the products if not given.

Returns:

The dataset STAC files, in PRODUCTS order, as a stream of YAML documents.

elevation.distclean(cache_dir=None, product=DEFAULT_PRODUCT)#

Remove the product cache entirely.

Parameters:
  • cache_dir – Root of the DEM cache folder.

  • product – DEM product choice.

elevation.info(cache_dir=None, product=DEFAULT_PRODUCT)#

Show info about the product cache.

Parameters:
  • cache_dir – Root of the DEM cache folder.

  • product – DEM product choice.

Returns:

The product cache report.

elevation.resolve_cache_dir(cache_dir)#

Return the DEM cache folder to use, as an absolute path.

The cache_dir argument takes precedence over the EIO_CACHE_DIR environment variable, that takes precedence over the CACHE_DIR default.

elevation.seed(cache_dir=None, product=DEFAULT_PRODUCT, bounds=None, max_download_tiles=MAX_DOWNLOAD_TILES, *, margin=MARGIN)#

Seed the DEM to given bounds.

A remote product is not downloaded whole: only the chunks of the store that cover the bounds are read in place and cached.

Parameters:
  • cache_dir – Root of the DEM cache folder.

  • product – DEM product choice.

  • bounds – Output bounds in ‘left bottom right top’ order.

  • max_download_tiles – Maximum number of tiles to download.

  • margin – Decimal degree margin added to the bounds. Use ‘%’ for percent margin.

Returns:

The datasource root and the bounds with the margin applied.

elevation.selfcheck(tools=TOOLS, verbose=False)#

Audit the system for issues.

Parameters:
  • tools – Tools description, defaults to TOOLS.

  • verbose – Report each tool as it is tested.

elevation.CACHE_DIR: str#
elevation.DEFAULT_GDAL_OPTIONS = '-co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co NUM_THREADS=ALL_CPUS'#
elevation.DEFAULT_OUTPUT = 'out.tif'#
elevation.DEFAULT_PRODUCT = 'MAPZEN'#
elevation.MARGIN = '0'#
elevation.MAX_DOWNLOAD_TILES = 25#
elevation.PRODUCTS = ['MAPZEN', 'GLO-30', 'AW3D30', 'SRTM1_GEOID', 'SRTM1_ELLIP', 'GEDTM30', 'GLO-90', 'SRTM3']#
elevation.RETIRED_PRODUCTS: dict[str, str]#
elevation.TOOLS: list[tuple[str, str]] = [('gdal_translate', 'gdal_translate --version'), ('gdalbuildvrt', 'gdalbuildvrt --version'),...#