Overview
Theproviders module defines interfaces and implementations for accessing elevation data from various raster sources, including ASCII tile collections and large GeoTIFF files.
RasterProvider
Abstract base class for all elevation data providers.Abstract Methods
get_elevation
Retrieve elevation at projected coordinates.X coordinate in the provider’s native CRS (typically UTM meters)
Y coordinate in the provider’s native CRS
None if outside coverage
Optional Methods
prepare_region
Pre-load or pre-cache data for a region before heavy sampling.Center X coordinate
Center Y coordinate
Radius in meters to prepare
Optional callback function for progress reporting
get_native_crs
Return the coordinate reference system of the provider."EPSG:25831" for UTM 31N)
transform_coordinates
Convert WGS84 lat/lon to provider’s native CRS.Latitude in decimal degrees (WGS84)
Longitude in decimal degrees (WGS84)
AscRasterProvider
Provider for ESRI ASCII Grid tile collections (e.g., ICGC 5×5km tiles).Parameters
Directory containing ASCII Grid (.txt or .asc) files
Methods
initialize
Scan the tiles directory and build spatial index.Optional callback for progress reporting
prepare_region
Load tiles within radius of center point into cache.Optional callback that returns
True to abort loadingCaching Behavior
- First parse: ASCII files are parsed (~500ms per 5×5km tile)
- Binary cache: Parsed tiles are saved as
.npyfiles (~10ms to load) - Memory cache: Tiles are kept in memory for fast repeated access
Example
TiffRasterWindowProvider
Provider for large single GeoTIFF files (e.g., Copernicus 30m DEM).Parameters
Path to the GeoTIFF file
Characteristics
- Window-based reading: Extracts only needed regions
- Thread-safe: Uses
RASTERIO_LOCKfor concurrent access - Bilinear interpolation: Sub-pixel elevation sampling
- Memory efficient: Does not load entire raster
Example
See Also
- Horizon Engine - Uses providers for DEM sampling
- Terrain Worker - Background processing with providers
- Data Sources - Where to obtain DEM data