terrain-rgb-query
Query elevation values from an rgb-encoded tileset
install
Right now, install via github
$ git clone git@github.com:dnomadb/terrain-rgb-query.git
$ cd terrain-rgb-query
$ npm install && npm link
usage
While you can use terrain-rgb-query
on any tiled, RGB-encoded elevation datasource,
it was primarily written to query mapbox.terrain-rgb
. You'll need a valid Mapbox Access Token for this.
API
// a templated url to query against -- needs to include {z}/{x}/{y}const template = "https://a.tiles.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token={your MapboxAccessToken here!}";const TRGB = template;const lnglat = -12216579 4292128; TRGB // If you have more than one to query use queryElevations -- tiles are cached so tile// requests are uniqueconst lnglats = -12216579 4292128 -12217579 4293128;TRGB // optionally, you can specify a zoom level to query [default=14]const zoom = 10;TRGB
CLI
You'll need a valid mapbox access token exported to your environment:
$ export MapboxAccessToken=pk.{....}
Then you can query elevations by lng, lat:
$ get-elev '[-122.16579, 42.92128]'2170.7000000000007 $ get-elev '[[-122.16579, 42.92128], [-122.16579, 42.92128]]'[2170.7000000000007,2170.7000000000007]
Browser
Barebones demo application in /demo
-- click on map to query elevation.
$ npm start
And then open http://localhost:5000/demo/