procgenlib.input.elevmodel package

class procgenlib.input.elevmodel.Format(value)

Bases: Enum

Supported elevation data file formats.

HGT = 'hgt'

Uncompressed .hgt files.

ZIP = 'zip'

Zipped .hgt files.

class procgenlib.input.elevmodel.HgtTileProvider(path, *, format, case_convention, zip_pattern)

Bases: object

Base class for loading 1-arcsecond elevation tiles in HGT format.

Instances are callable: given a tile’s integer latitude and longitude, they return a (3601, 3601) int16 NumPy array of elevation values in meters. Data is returned in south-to-north order per ISO 6709.

When called:

Parameters:
  • lat – Tile latitude (south-west corner), positive for north.

  • lon – Tile longitude (south-west corner), positive for east.

Returns:

A (3601, 3601) int16 array of elevation values in meters, ordered south-to-north.

class procgenlib.input.elevmodel.NASADEM_HGT(path, *, format)

Bases: HgtTileProvider

Tile provider for NASADEM HGT data.

Parameters:
  • path – Directory containing the NASADEM tile files.

  • format – File format (Format).

class procgenlib.input.elevmodel.SRTMGL1(path, *, format)

Bases: HgtTileProvider

Tile provider for SRTM Global 1-arcsecond (SRTMGL1) data.

Parameters:
  • path – Directory containing the SRTMGL1 tile files.

  • format – File format (Format).

procgenlib.input.elevmodel.extract(tile_provider_fn, min_latitude, min_longitude, max_latitude, max_longitude, allow_gaps)

Extract elevation data for the given latitude and longitude spans (inclusive of endpoints).

The convention is as per ISO 6709: north latitude is positive, east longitude is positive, decimal degrees are used

Parameters:
  • min_latitude (float)

  • min_longitude (float)

  • max_latitude (float)

  • max_longitude (float)

  • allow_gaps (True) – If a tile file is missing, assume it’s ocean and fill with zeros

  • tile_provider_fn (Callable[[int, int], ndarray])

Returns:

a tuple (height, latitude_span, longitude_span) where height is a 2D numpy array of int16 with elevation data in meters

Return type:

Tuple[ndarray, float, float, float, float]