tatry

Elevation API server.

Usage no npm install needed!

<script type="module">
  import tatry from 'https://cdn.skypack.dev/tatry';
</script>

README

NPM version Build Status Dependency Status Dev Dependency Status

tatry

Fast and simple Elevation API server.

Install

$ npm --global install tatry

tatry requires dataset to work. Please refer to open-elevation project on how to download and prepare the dataset. tatry only works with regular TIFF files, uncompressed with elevation data kept as Int32 pixels.

You can use gdal_translate to convert your data.

# to decompress TIFF
gdal_translate -co "COMPRESS=none" in.tif out.tif

# to convert data to Int16 per pixel
gdal_translate -ot Int16 -strict in.tif out.tif

You may need to split large (>4GB) files into smaller parts since tatry does not support BigTIFF file format.

Data does not have to cover contiguous area. Where tatry finds a point that is represented by multimple tiles it will attempt to use the highest resolution data. Results are automatically interpolated using bilinear interpolation.

Configuration

The following environment variables can be specified:

  • TATRY_PORT - port on which server listens - defaults to 3080
  • TATRY_DATA_PATH - location of .tif files - defaults to /var/lib/tatry
  • TATRY_WORKERS - number of workers threads - defaults to 2
  • TATRY_CACHE_SIZE - size of the .tif tile cache, the bigger it is the more .tif info will be kept in memory - defaults to 100mb
  • TATRY_BODY_LIMIT - maximum size of JSON body parsed - default to 250kb

tatry will initialize its environment from /etc/default/tatry file

API

V2

GET /api/v2/lookup?lls=lon_1,lat_1|lon_2,lat_2

Looks up elevation for one or more points. Each point is specified as longitude,latitude pair (think x,y). Points are separated with |.

Example:

/api/v2/lookup?lls=-160,30|100,-45

Result is return as JSON and contains a single results property which is an array of { ll, elevation } tuples.

{
  "results": [
    {
      "ll": [ -160, 30 ],
      "elevation": 100
    },
    {
      "ll": [ 100, -45 ],
      "elevation": -3.5
    }
  ]
}

POST /api/v2/lookup

Looks up elevation for one or more points. Parameters are sent in JSON body. lls parameter contains an array of longitude,latitude pairs.

{
  "lls": [
    [ -160, 30 ],
    [ 100, -45 ]
  ]
}

Result is the same as GET request result.

V1

V1 API is compatible with open-elevation API - click for details

Acknowledgments

Big thank you to João Ricardo Lourenço A.K.A @Jorl17 and @Developer66 for their work on open-elevation project.

License

MIT © Damian Krzeminski