Single Point Elevation
How to get the elevation of a latitude/longitude point on the planet? The Google Api costs money. The stadiamaps version is only in the paid plan too. So what is the alternative?
There is open-elevation and it is opensource. So lets try to run this ourselves. The whole setup needs some memory (4GB), CPU and disk space (40G) so I used a Hetzner VPC to run it. I used the smallest possible VPC for the problem (a CPX21, 4GB memory, 80G disk) that costs 1.4 cent per hour. The image I used is the "Docker CE" app (based on Ubuntu 22.04), because we mainly need Docker. The server needs an IPv4 address to communicate with Github and cgiar.org.
Open-elevation has a howto for self hosting. We try to follow this step by step with minor modifications. The first modification is by using a fork that has fixed the moving of the extracted archives. The elevation data is downloaded from https://srtm.csi.cgiar.org automatically and is about 2G of data. The disk space needed is about 40G (20G when finished extraction and processing). The second modification is the change of the -v option to the current folder and not only data. It didn't work otherwise, but your mileage may vary.
I used the default root user for all of this because I only needed the setup to process a list of geo points. When using this to host a public version I would have created a user. Another thing I am ignoring is SSL – so no https.
There is no progressbar after download and extraction for the tile creation. And this takes a few minutes.
Command log:
# using the fork, not the original git clone https://github.com/CelticJasen/open-elevation cd open-elevation mkdir data # download and process the tiles docker run -t -i -v $(pwd):/code openelevation/open-elevation /code/create-dataset.sh # running the webservice docker run -t -i -v $(pwd):/code -p 80:8080 openelevation/open-elevation
Next we try to use the API and query a single point to test the accuracy: The height of the Feldberg which is the highest mountain in the black forest with 1493 meters.
curl http://<IP-ADDRESS-OF-YOUR-SERVER>/api/v1/lookup?locations=47.8739912,8.0046735 # {"results": [{"latitude": 47.8739912, "longitude": 8.0046735, "elevation": 1490}]}
The result is close enough.
Finally processing a list of points within one api call:
curl -X POST http://<IP-ADDRESS-OF-YOUR-SERVER>/api/v1/lookup --header "Content-Type: application/json" \ --data '{"locations": [{"latitude": 52.37313,"longitude": 4.89135},{"latitude": 59.32687,"longitude": 18.07035}]}' # {"results": [{"latitude": 52.37313, "longitude": 4.89135, "elevation": 14}, {"latitude": 59.32687, "longitude": 18.07035, "elevation": 28}]}%