NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


Hello, can anyone point me in the direction of how one might be able to extract OSM feature information from a GPX file. For example, I would like to determine all the peaks that may have been summited on a GPS track.

asked 06 Sep '18, 22:56

ClarionRunner's gravatar image

accept rate: 0%

edited 14 Sep '18, 21:36

aseerel4c26's gravatar image

aseerel4c26 ♦

Do you think of adding these peaks to OSM (contribution) or do you think of, instead, querying the OSM data for nearby peaks (possibly with name infomation) (usage)?

(08 Sep '18, 19:58) aseerel4c26 ♦

the latter querying the OSM data for nearby peaks

(08 Sep '18, 20:05) ClarionRunner

The Overpass API around filter queries for elements within a given radius (in meters) along a linestring when given a list of lat/lon pairs:


For example (in Overpass Turbo):

out meta;


There might be better ways, but here is a one-liner for the Linux/Ubuntu command-line to convert a GPX track to the expected linestring format:

ogr2ogr -f CSV /vsistdout/ brouter.gpx tracks -lco GEOMETRY=AS_WKT -simplify 0.001 | \
tail -n +2 | \
sed -e 's/.* (\+\([^)]*\))\+".*/\1/' -e 's/\([0-9\.]*\) \([0-9\.]*\),\?/\2,\1,/g' -e 's/,$//'
  • example GPX track created using an online router
  • uses GDAL ogr2ogr converter (requires gdal-bin package)
    with GPX and CSV with WKT (Well-known Text) formats, as this comes close to expected format
  • outputs to console with "/vsistdout/"
  • "simplify" reduces number of nodes, distance tolerance in degrees, 0.00001° about 1 meter, depending on latitude
  • "tail" skips csv header
  • "sed" extracts coordinates, flips lon/lat and uses all comma, removes trailing comma
permanent link

answered 14 Sep '18, 20:39

ikonor's gravatar image

accept rate: 18%

edited 14 Sep '18, 20:43

Thank you so much!!!! Just what I was looking for :)

(17 Sep '18, 07:05) ClarionRunner

how would I pass this query to from a php file?

(17 Sep '18, 07:58) ClarionRunner

The custom shortcut "{{latlons}}" only works in Overpass Turbo. Elsewhere, you need to replace it yourself. You can get an interpreter URL from Overpass Turbo with Export > Data > raw data from Overpass API interpreter: Or use a POST request, see

(17 Sep '18, 08:42) ikonor

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 06 Sep '18, 22:56

question was seen: 3,780 times

last updated: 17 Sep '18, 08:42

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum