runalyze / dem-reader
Read digital elevation files such as GeoTIFF files for srtm data or similar.
Installs: 21 816
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: >=8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-18 20:05:32 UTC
README
Library to read digital elevation models, such as GeoTIFF files for SRTM. The GeoTIFF reader itself is originally based on Bob Osola's SRTMGeoTIFFReader.
Usage
use Runalyze\DEM\Reader; use Runalyze\DEM\Provider\GeoTIFF\SRTM4Provider; $Provider = new SRTM4Provider('path/to/srtm/files'); $Reader = new Reader($Provider); $elevations = $Reader->getElevations($latitudes, $longitudes);
To give you some more details: Each provider is valid for its own. You can just ignore the general reader and use your favorite provider:
use Runalyze\DEM\Provider\GeoTIFF\SRTM4Provider; $Provider = new SRTM4Provider('path/to/srtm/files'); $elevations = $Provider->getElevations($latitudes, $longitudes);
But you may have more than one provider available or different paths where your dem files are located. You can attach as many providers as you want to the reader. Each of them will be checked if it can handle the given elevation data (in the order they were attached) and the wirst one that does will be used.
use Runalyze\DEM\Reader; use Runalyze\DEM\Provider\GeoTIFF\SRTM4Provider; $Reader = new Reader(); $Reader->addProvider(new SRTM4Provider('path/to/europe/srtm/files')); $Reader->addProvider(new SRTM4Provider('path/to/america/srtm/files')); $europeElevations = $Reader->getElevations($europeLatitudes, $europeLongitudes); $americaElevations = $Reader->getElevations($americaLatitudes, $americaLongitudes);
License
Code released under the MIT license.