Python tool for download gpx from sequences

I’m writing a tool for download gps traces extracted from the sequences.

look the script here

by the moment it works ok.

tell me if you would like to have a new functionality.


Nice tool!
However, I can’t open those tracks in Basecamp/Mapsource, I think Garmin requires a stricter format of GPX, but I dont know exactly how.
I can open those tracks in JOSM, and save it as gpx, but I have to do this for each single track. With several hundreds of tracks this is not possible. Can you write/append all tracks in one single gpx file?

This way I can convert it easier to Basecamp for my Garmin GPS with tools like Javawa’s IMGfromGPX or mkgmap.

I tried with gpsbabel, but I can’t get a good output :weary: . I will add a option for paste all track in one file.

hey! look my last script to join your gpx files in just one.

this scripts is a fast way to join a lot of GPX files downloaded from mapillary
if you use , this is your second step for join
all in just one file.

use this script as:

python [gpx_directory] [outputfile.gpx]

ex: python gpx_from_sequences salida.gpx

enjoy it.

1 Like

Thanks for the update Danilo,
I can now open it with Mapsource, so the structure is now a valid xml file.
But there is still one problem. It makes one big gpx track, so it connects the last point of the first file with the first point of the second file. This creates one big mess of straight lines.
Better is:

    <name>track 1</name>
      <trkpt lat="xx.x" lon="y.yy"/>
      <trkpt lat="xx.x" lon="y.yy"/>

    <name>track 2</name>
      <trkpt lat="xx.x" lon="y.yy"/>
      <trkpt lat="xx.x" lon="y.yy"/>

I have done some search and replace with

<trkseg> to <trk><trkseg> and </trkseg> to </trkseg></trk>

which works for me!

With some effort I managed to convert the gpx file with Javawa’s IMGfromGPX tool to a transparent Garmin maplayer to use on my GPS, great! Now I can see easily what streets have to be done for Mapillary :sunglasses:

1 Like

Hi Danilo,

Another issue:
It seems the bbox that I specify does not work. For instance if I use this command to get all the sequences in my area,

python 51.9 52.4 5 6 1000

It starts to download all sequences all over the world. I also tried to edit the parameters in the py file, like

MIN_LAT_G = 51.9
MAX_LAT_G = 52.4

But this doesnt work either, again the script begins to search for the whole world.

I have found the cause, a bug in the code(line 52-54), you have ‘min-lat’, ‘max-lat’, ‘min-lon’, ‘max-lon’,
should be ‘min_lat’, ‘max_lat’, ‘min_lon’, ‘max_lon’,

I repared this issues and works better now!! thanks for your comments and support. it’s amazing tool now.

1 Like

@dalacost Thanks for this, I actually wanted for a while now to have a gpx file of all sequences in my town, to use in osmand. It’s still not perfect, because osmand needs 2 minutes to render a 200.000 points gpx file, but it’s the most useful tool I have now to see unmapped places in osmand. Thanx!

edit: I’ve got a much better render time now I removed 90% of all nodes with josm.

Thanks Danilo!
For Osmand I have now the following workflow

  1. open gpx file in Josm
  2. Select GPX and convert it to data
  3. Select all tracks (ctrl-A)
  4. Choose an existing OSM tag, which is not used in your area, in NL I can use piste:type=downhill
  5. Save the data layer in osm format, eg map.osm
  6. Convert map.osm to an obf osmand map with OsmandMapcreator,
  7. Copy map.obf to the osmand working directory on your device

Result in wintersport style:

@dalacost Maybe a nice improvement for your tool is to add a date from which you can start extracting the sequences. Now it will grab all sequences from an area, if I want to update this area later, I would like to see only the latest sequences that I didnt download the last time. By giving a date range you can also see which sequences are rather old and needed to be updated in the field. Something like
with min and max date

that’s is a great idea. I will try to learn how to do that.

thanks for patience, new version is finish. I added support for limit dates as you requested, and other improvements. (estimated time, and a new comfortable way to use options as unix style)

check the last code here:

actually is in a pullrequest for mapillary tools :smile:

enjoy it.

1 Like

Thanks for implementing these features!
I did a test but unfortunately it failed.

My command is:
python -r 51.9 53 4.86 7.1 -m 19999 -d1 20151030

This is the error message, what does it mean?

Traceback (most recent call last):
File “”, line 182, in
limit_start_time = int(datetime.datetime(int(limit_start_time[:4]),int(limit_start_time[4:6]),int(limit_start_time[6:8]),0,0).strftime(’%s’)) * 1000
ValueError: Invalid format string

i’m not sure. i can’t get your problem… :frowning:

dalacost@dalacost-desktop:~/Descargas$ wget
--2015-11-05 12:48:47--
Resolviendo (
Conectando con ([]:443... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 7881 (7,7K) [text/plain]
Grabando a: “”

100%[==================================================================================================================================================>] 7.881       --.-K/s   en 0s      

2015-11-05 12:48:47 (904 MB/s) - “” guardado [7881/7881]

dalacost@dalacost-desktop:~/Descargas$ python -r 51.9 53 4.86 7.1 -m 19999 -d1 20151030
Warning: USER NOT SPECIFIED - NOT A GOOD IDEA, trying to list last gpx from all users
Getting the files list...
Result: 11 sequences in area.
Log file at gpx_from_sequences/downloaded_20151105.txt
Successfully downloaded: 20151105_y6buq8NEZfol-StqN9ZLeg.gpx 1/11 ET ...
Successfully downloaded: 20151103_VPDf7drUMahl8v19asIG4w.gpx 2/11 ET ...

dalacost@dalacost-desktop:~/Descargas$ python -V
Python 2.7.6

I’m using Windows 7 / 64 bits pc, maybe the date notation is different on each OS?

ok, thanks for report it. I will check and back to you.

problem was resolved.
Thanks to ligfietsen for help me on this.