Ever needed to find the height above sea level? Here’s a method to pull altitude data into Excel either from latitude and longitude, or a city name, address, postcode, or anything else that resolves to a location on Google Maps.

Seeing as the various Google Maps API posts on here seem to be so popular, when I saw Google’s elevation API I thought it should probably join distance, journey time and latitude & longitude in having an Excel function written for it.

It’s not that difficult. The form is pretty much the same as the others so I’ll just put it here.

To call it just enter =G_ELEVATION(LatLng) in a cell. LatLng there should be a reference to a cell which contains a latitude and longitude in the form “0.0000000,0.0000000”. If your latitude and longitude are in separate cells can use =G_ELEVATION(Lat&","&Lng).

You could even daisy-chain it with the latitude and longitude function like =G_ELEVATION(G_LATLNG("London, England")) to return London’s height above see level. It’s 20.23 meters, apparently.

Jamie Bull | mail@oco-carbon.com

Related Posts

WiGLE is a popular platform which can be used for finding the location of a device using the names of WiFi networks in its vicinity. I’ve written about this before, and wrote some Python code to interact with their API. This API has since been retired and replaced with a new one, as of December […]

Just a quick post to point out a couple of really useful tools.The first is a web-based tool for finding weather files for a location of interest. It’s similar to the Excel EPW finder tool we created a few years back, but much more modern looking. It is however missing a few of the useful […]

Eppy is a really useful library which I’ve written about several times, since before I really had anything to offer in terms of contributing code. Over the past year or so though, I’ve started to contribute back some of the changes and additions I’ve made while using eppy on academic and commercial projects.This post is […]

14 Comments on “Altitude in Excel – Google Elevation API”

  • Pegah says:

    How precise is it?

    • Jamie Bull says:

      According to the API documentation, “The Elevation API returns data for single point queries of the highest accuracy possible.” Which isn’t much help, I grant you. From testing it it looks suspiciously smooth. It certainly doesn’t seem to be picking up objects at a building scale.

      • anon says:

        for negative lat longs, doesn’t seem to work for me
        eg. G_ELEVATION(G_LATLNG(“London, England”))
        creates a url with a space before the -0.1198
        http://maps.googleapis.com/maps/api/elevation/xml?&locations=51.5112, -0.1198&sensor=false

        change the line above, put in ‘replace’

        myRequest.Open “GET”, Replace(“http://maps.googleapis.com/maps/api/elevation/xml?” _
        & “&locations=” & LatLng & “&sensor=false”, ” “, “”), False


  • JimC says:

    Never had a need to determin elevation – until today.
    Now I have a file full of Lat/Long data and ~ “Wouldn’t it be swell if we could get elevation?”.
    Your post helped me solve that problem in seconds.
    Thanks for sharing the knowledge.

  • Niels Goossens says:


    Really like your function, though when I try to ruin t, it says “user-defined type not defined” for the three DIM lines of code in the beginning. Any idea how to solve it?

    Thanks in advance


  • Fuzail Khan says:

    Thanks a lot, It worked perfect for my task

  • Marius C. says:


    thanks for the work.
    I have an issue.
    I don’t know why, the elevation given to me is always 0.
    I added your code to the module : G_geocoding but when I enter the function in the excel cell with a link to a GPS position, it doesn’t work.

    Do you have any idea ?

    Thanks a lot

    • Jamie Bull says:

      What format is your latitude/longitude string in? It needs to be like “0.00,0.00”, so with decimal points in each of the numbers rather than commas.

      • Marius C. says:

        Yes it was like that.
        I used your file and the first sheet
        in the column lat/long to test, but
        it gives me a 0.

        • Erik S says:

          I had a similar problem. Solved it by changing to format of function from a double to a string. Since I use comma as a decimal
          separator it did not understand that it was a value and returned #value.

Leave a Reply

Your email address will not be published. Required fields are marked *