Practical Tools with Python — Google Elevation API

Hakan KOCAMAN
4 min readNov 24, 2020

Last year I participated in a group nature walk. As we climbed a high hill, everyone in the group started to say the values ​​they obtained from different sources regarding the altitude of the highest point of the hill we will climb. Consequently, the values ​​obtained from different sources did not coincide with each other. The last topic turned around and came to me. The expectation of the group is that I would say that one of the sources belonging to these values ​​is the best; I cannot say that none of them are the most correct or the most wrong, frankly, these sources offer values ​​based on the models they have made, that the accuracy may vary between the sources, in this context, precise measurement should be made for the most accurate result, otherwise, if there is no variation between them, even the part of unemployed could remain within the scope of hiking we have done alone, plus / minus, I stated that the acceptable level of variability in 5-meter. And so we continued the walk where we left off.

What is Google Api?

Google API to communicate with and developed by Google and the Google Services are application programming interface, allowing them to integrate with other services. Examples of these are Search, Gmail, Translate, or Google Maps. Wikipedia (in English)

Vertical Datum and Google Elevation Api

Today, it is very difficult to accurately calculate or determine the vertical position as opposed to the horizontal position. Because the vertical position is more complicated than the horizontal position. The main reason for this is that the Earth does not have a mathematical surface such as a sphere or an ellipsoid, and the plume curve and the average sea surface vary due to the difference in gravity from place to place. However, with the map services provided by Google Company worldwide and the APIs it offers for the use of these services, users can obtain some data for practical use. Here is the Google Elevation Api ‘is one of them. With the Google Elevation API, it is possible to provide the sea level elevation of any point on the earth by using the latitude and longitude values ​​of the geographic coordinates in the WGS84 datum. Of course, things you do in terms of the accuracy of the data provided by Google and decide to what extent it is entirely up to you enough about the sensitivity of the situation. With the Google Elevation Api, you can get free altitude information of 2500 points per day. To have the Google Elevation Api key, all you have to do is log into the Google Cloud Platform with your Google account at https://console.cloud.google.com/.

So how did the Google Elevation Api tool come about with Python? One day, a cartographer from the business unit came to me and said that they needed elevation data for nearly eight hundred network structures scattered throughout the province. Of course, since the height of so many points is not possible to go to the field and measure it as soon as possible, I asked him whether the altitude data we will obtain with an accuracy of 5–10 meters will work. Based on the positive response I received, I quickly coded the Google Elevation Api tool with Python and converted the coordinates of these points to WGS84 geographic coordinates and provided the elevation data on the same day and delivered it to the relevant mapper friend.

Using Google Elevation Api with Python

To obtain the altitude information, all you have to do is save and close the file by copying your current coordinates to the “coordinate.txt” file in the same directory (your geographic coordinate pairs should be copied in longitude latitude order and with spaces between them). Then run the code written in Python in your compiler. Thus, the height value corresponding to each of the WGS84 geographic coordinates in the “coordinate.txt” file will be queried over the Google Elevation Api service and written into the same file and the process will be completed in this way.

Yes, as can be seen in the incident I have described above, today there are many sources that offer different values ​​regarding the height of a point on the earth. To reach the most accurate result, it is necessary to measure precisely and to master the vertical datum issue. As I mentioned before Single least, the resources related to the work I have done gives us an adequate level of accuracy and precision, then why not use it?

GitHub: https://github.com/hakankocaman/PratikPythonAraclari/blob/master/Google_Elevation_API.py

For Turkish content, please visit: Python ile Pratik Araçlar — Google Elevation API | Hakan KOCAMAN

--

--