I have a program that downloads and process GPX tracks from OpenStreetMap using:


But how can I find the ID of the latest uploaded GPX file?

Currently I get the ID from:


But that data is mostly meant to be read by humans, and needs a lot of parsing - is there a better way?

asked 08 Sep '10, 07:15

Johnny%20Carlsen's gravatar image

Johnny Carlsen
accept rate: 0%


Your question is fine as it is, but it's very specific. If you can tell us more about what you're trying to do in general, there may be a way of acheiving it without having to scrape the traces page.

(10 Sep '10, 16:23) Jonathan Ben...

Well you can always use the rss feed, just extracting the link element with a regexp will work.



curl http://www.openstreetmap.org/traces/rss |
sed -r 's|.+s/([0-9]+)</link>|\1|;t;d'|
head -1

But compare that to parsing the html page there is almost no gain.



wget -O - "http://www.openstreetmap.org/traces" |
sed '/traces/!d; s|.* href="/user/[^/]*/traces/\([0-9]*\)" .*|http://www.openstreetmap.org/traces/\1/data|;t;d'|
head -1
permanent link

answered 10 Sep '10, 12:08

emj's gravatar image

accept rate: 15%

edited 11 Sep '10, 00:03

As the API doesn't seem to have a way of retrieving the newest GPX trace ID, here is an example of a shell command to grab the ID from the traces page:

curl -s "http://www.openstreetmap.org/traces" | grep -m 1 "/edit?gpx=" | cut -d "=" -f3 | cut -d "\"" -f1

But of course this might stop working in the future as the layout of the page may change.

permanent link

answered 08 Sep '10, 10:45

scai's gravatar image

scai ♦
accept rate: 23%

Your answer
toggle preview

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](http://url.com/ "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: 08 Sep '10, 07:15

question was seen: 3,806 times

last updated: 11 Sep '10, 00:03

powered by OSQA