This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

programmatically download gps trace

0

No luck with help.openstreetmap.org, so I am asking what is probably a very elementary question.

How can I download programmatically a GPS trace file which is available at

https://www.openstreetmap.org/trace/traceidnumber/data

i.e. how can I do this with a script?

I presume the answer is somewhere in the API wiki documentation , but it's outside of my zone of familiarity (e.g. python or bash).

Note: I don't want to download bulk data, I simply want to be able to automate the download of, say, a dozen GPS trace files.


Edit: The reason of my failure was that I had made a mistake in constructing the URL...

For the record, the following python code snippet works just fine:
import requests from pathlib import Path url = "https://www.openstreetmap.org/trace/3116621/data" path = Path.home()/'datasets' r = requests.get(url) with path.open('wb') as f: f.write(r.content)

asked 29 Sep '19, 16:44

Antoine%20C's gravatar image

Antoine C
21112
accept rate: 0%

edited 29 Sep '19, 21:23


One Answer:

2

The top public trace at the moment just happens to be this one. On that page is a download link, which is https://www.openstreetmap.org/trace/3116621/data. If you get that (via e.g. "wget" or within your programming language of choice) I'd expect that you'll get that trace. I've just done this:

wget https://www.openstreetmap.org/trace/3116621/data

and what I get looks like a GPX file to me. You could do that as part of a script. Does this answer the question, or do you need to know how to find out the trace ID, or something else?

This answer is marked "community wiki".

answered 29 Sep '19, 17:08

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Yes that answers my question!

I was not able to do this in python using its requests package - don't know why. (It downloads an html file which somewhere says "File not found".)

To answer your question, I am fine finding trace id (in python using an html parser).

(29 Sep '19, 17:16) Antoine C

Source code available on GitHub .