https://github.com/itinero/srtm
A library to load SRTM data and return heights in meter.
https://github.com/itinero/srtm
csharp itinero srtm
Last synced: 10 months ago
JSON representation
A library to load SRTM data and return heights in meter.
- Host: GitHub
- URL: https://github.com/itinero/srtm
- Owner: itinero
- License: mit
- Created: 2017-11-07T16:03:42.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2022-01-09T15:41:38.000Z (over 4 years ago)
- Last Synced: 2025-08-01T04:46:49.415Z (11 months ago)
- Topics: csharp, itinero, srtm
- Language: C#
- Homepage:
- Size: 3.13 MB
- Stars: 21
- Watchers: 3
- Forks: 12
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SRTM
[](https://github.com/itinero/srtm/actions/workflows/build.yml)
[](https://gitter.im/Itinero/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[ ](http://www.itinero.tech/)
[](https://github.com/itinero/srtm/blob/master/LICENSE.md)
- SRTM: [](https://www.nuget.org/packages/SRTM/)
A simple library to load SRTM data and return heights in _meter_ for a given lat/lon. Based on [Alpinechough.Srtm
](https://github.com/alpinechough/Alpinechough.Srtm).
## Usage
```csharp
// create a new srtm data instance.
// it accepts a folder to download and cache data into in addition to the source you want to use for the data.
// USGS data is immediately available, but is of a lower resolution.
var srtmData = new SRTMData(@"/path/to/data/cache", new USGSSource());
// NASA data is of a higher resolution, but requires creating an account at https://urs.earthdata.nasa.gov/users/new/.
var credentials = new NetworkCredential("username", "password");
var srtmData = new SRTMData(@"/path/to/data/cache", new NASASource(credentials));
// get elevations for some locations
int? elevation = srtmData.GetElevation(47.267222, 11.392778);
Console.WriteLine("Elevation of Innsbruck: {0}m", elevation);
elevation = srtmData.GetElevation(-16.5, -68.15);
Console.WriteLine("Elevation of La Paz: {0}m", elevation);
elevation = srtmData.GetElevation(27.702983735525862f, 85.2978515625f);
Console.WriteLine("Elevation of Kathmandu {0}m", elevation);
elevation = srtmData.GetElevation(21.030673628606102f, 105.853271484375f);
Console.WriteLine("Elevation of Ha Noi {0}m", elevation);
// if a smoother result is preferred, it is possible to use bilinear interpolation at the cost of some accuracy
double? smoothElevation = srtmData.GetElevationBilinear(47.267222, 11.392778);
Console.WriteLine("Elevation of Innsbruck: {0}m", elevation);
smoothElevation = srtmData.GetElevationBilinear(-16.5, -68.15);
Console.WriteLine("Elevation of La Paz: {0}m", elevation);
smoothElevation = srtmData.GetElevationBilinear(27.702983735525862f, 85.2978515625f);
Console.WriteLine("Elevation of Kathmandu {0}m", elevation);
smoothElevation = srtmData.GetElevationBilinear(21.030673628606102f, 105.853271484375f);
Console.WriteLine("Elevation of Ha Noi {0}m", elevation);
```
## Data sources
We implemented two sources of data, the [USGS SRTM](https://dds.cr.usgs.gov/srtm/version2_1/SRTM3/) and [NASA SRTM](https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/). If you want to add an extra source, we're accepting pull requests, you just need to implement [something like this](https://github.com/itinero/srtm/blob/master/src/SRTM/Sources/USGS/USGSSource.cs).
## We need help!
If you think we need to add another source of data **let us know via the issues**, if you know more about SRTM or of another source of elevation, also **let us know**.