SRTM v0.4.0 SRTM View Source

SRTM is a small library that provides a simple interface to query locations on the earth for elevation data from the NASA Shuttle Radar Topography Mission (SRTM).

Examples

{:ok, client} = SRTM.Client.new("./cache")
#=> {:ok, %SRTM.Client{}}

{:ok, elevation, client} = SRTM.get_elevation(client, 36.455556, -116.866667)
#=> {:ok, -51, %SRTM.Client{}}

Link to this section Summary

Functions

Queries locations on the earth for elevation data.

Link to this section Functions

Link to this function

get_elevation(client, latitude, longitude) View Source
get_elevation(
  client :: SRTM.Client.t(),
  latitude :: float(),
  longitude :: float()
) ::
  {:ok, elevation :: float(), client :: SRTM.Client.t()}
  | {:error, error :: SRTM.Error.t()}

Queries locations on the earth for elevation data.

If the corresponding file can't be found in the cache, it will be retrieved online.

Returns the elevation in meters.

Note:

  • Make sure to match on the client to always use the latests client struct. Otherwise SRTM files will be re-read into memory on every call!

  • The SRTM Files are cached in memory. Querying many coordinates at different locations on Earth may therefore take up a lot of memory space. See SRTM.Client.purge_in_memory_cache/2.

Examples

iex> {:ok, client} = SRTM.Client.new("./cache")
iex> {:ok, elevation, client} = SRTM.get_elevation(client, 36.455556, -116.866667)
iex> elevation
-51