[SOLVED] command-line application to add elevation to GPX/KML files?


I’m surprised to see that GpsBabel doesn’t seem to support that feature, and Google didn’t help.

Do you know of a Windows command-line application that takes a GPX/KML file as input, grabs elevations from the Net, and outputs the whole thing into a new file?

Thank you.

Hi shohreh, would it not it be better if you asked it at GPSBabel and Google or Windows Fora & such ?

Possibly, although it couldn’t hurt to ask here were people handle GPX files routinely.

I don’t know a command-line program, but some GPX editors allow to add or correct the elevation data from DEM sources.
The general problem with this method is that the open source DEM data with its raster of 30m or more is too unprecise to calculate good elevation data. It would ignore bridges and tunnels and the fact that major roads are typically not following the surface, instead the earth is flattened before the road is build.
Some routing programs calculate elevation profiles which are more reasonable, e.g. brouter

Thanks for the info.

This script in Python relies on www.gpxz.io , whose free account allows for “1 request per second, 100 requests per day, 50 locations per request”.

As a multi-day trip involves more points, I’ll check out DEM.

Wow, their prices are quite high! But a precision of 1 m sounds great as well. I wonder why you don’t (re)plan your trip on a web page which offers gpx with elevation.

Because I needed a command line solution to edit existing GPX files.

For others’ benefit, here’s a script in Python that relies on the free SRTM database:

#pip install srtm.py
import srtm
import gpxpy

gpx = gpxpy.parse(open('input.no.el.gpx'))

elevation_data = srtm.get_data()
elevation_data.add_elevations(gpx, smooth=True)

with open('output.with.el.gpx', 'w') as f:

those DEM files have geoid elevation or above sea level? I found out they have quite a difference and nobody seems to use the geoid elevation in official business dealings.

I don’t know anything about DEM.

If you have a better public alternative, I’m interested.

Hi Robin Miller1, welcome, whats the difference between #2 & #10 ?

This has been a recurring pattern on this forum recently, where a new user just copies and pastes an earlier answer. They seem to be spammers of some kind - they may intend to edit the post later to add a link, or to add a link in their profile. I have reported several such posts.