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

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


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?

permanent link
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

Follow this question

By Email:

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

By RSS:

Answers

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:

×290
×275
×235
×68

question asked: 29 Sep '19, 16:44

question was seen: 2,249 times

last updated: 29 Sep '19, 21:23

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