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

3
1

I have a large number (many hundreds) of GPS tracks in gpx format which cover much of Britain, including some from other parts of the world. I want to pick out only those that pass through a specific small area of London. I can't think of an obvious way to do this short of viewing each one individually and saving relevant ones to a separate folder.

Can anyone suggest a way to automate this?

(Hope it's ok to post this as it's not strictly speaking an OSM question... but it relates to a project which will use OSM data.)

asked 04 Nov '15, 14:40

SDavies's gravatar image

SDavies
1615510
accept rate: 0%

edited 04 Nov '15, 20:13

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

could be useful to pick one track out of those many, and then upload this track to OSM. Then your question is related to OSM. :-)

(04 Nov '15, 20:04) aseerel4c26 ♦

could you please clarify what you mean by "automate"? Do you want to do this once? Do you want this to be strictly fully automatic?

(04 Nov '15, 20:15) aseerel4c26 ♦
1

As automated as reasonably possible-- ie is there some kind of software I could use to do this for me. I may want to do this again in future, but just a one off at this point.

(05 Nov '15, 05:25) SDavies

If you open a trace with a text editor you will see lats, lons, times and dates they may help you sort them. Was i in London then? or is it >51.3 and <51.7 north and/or between -.7 and +.2 lon.

(08 Nov '15, 22:27) andy mackey

Echoing the SK53 answer "I would turn to OSGeo tools for this", but instead of ogrinfo, use ogr2ogr to convert your GPX traces into a shape file (possibly running ogr2ogr multiple times with the same output file, using -append from the second run on), and then again use ogr2ogr with the -spat option and a London bounding box to select those traces that go through London. Then you can use QGIS to visualize them if desired.

In pseudo code:

ogr2ogr trails.shp track1.gpx
ogr2ogr -append trails.shp track2.gpx 
...
ogr2ogr -append trails.shp track999.gpx
ogr2ogr -spat -0.4 51.3 0.3 51.7 london-trails.shp trails.shp
qgis london-trails.shp

There's any number of potential traps here, e.g. how to keep attributes of your GPX file if you need them, or what happens if one GPX contains multiple tracks, or whether you want to process routes or tracks, etc., but with some patience and the right command line flags, things should turn out nicely.

The advantage of this more complex process is that it will actually look at the track, not only the bounding box. (Even though it will only allow a rectangular "London".)

Lastly, if you want to go super analytic on this, you could also import your shape file into a PostGIS database which would then allow you to check against a polygonal London boundary, or run queries like "which trails are in London for more than 50% of their length", "which trails are in London for more than 2km", or "which trails start in London and end more than 20km away" and whatnot.

And no, this question is not OpenStreetMap related and should have been asked elsewhere.

permanent link

answered 13 Nov '15, 23:16

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

alt text

This shows a picture of GPS prune with hundreds of footpath kml files of several counties, it will also display mutiple GPXes. Multiple traces can be added with ctrl select. If you zoom in and click on a trace it will tell you the trace's id and other info all displayed on over OSM. The kml are from http://www.rowmaps.com/ and prune is from here http://activityworkshop.net/software/gpsprune/ Prune may help you. and if you have an interest England's Rights of Way the other link is very useful.

permanent link

answered 08 Nov '15, 21:53

andy%20mackey's gravatar image

andy mackey
13.2k87143285
accept rate: 4%

edited 08 Nov '15, 21:56

I would turn to OSGeo tools for this.

A very quick check shows that ogrinfo will provide information about a wide range of files containing geographic information, including GPX. Part of this information is extents of the file, or layer. So post-processing gdalinfo output (as simple as grepping for "Extents" could provide you a listing of the extents for each gpx file.

Once you have the information it may be useful to store it in a spatial database to easily relocated relevant GPX files.

permanent link

answered 06 Nov '15, 11:43

SK53's gravatar image

SK53 ♦
28.1k48268433
accept rate: 22%

Hmm, does "extents" mean the bounding box of the trace? This may not be useful if "passing" (from the question) means that the trace actually runs trough an area (what I have understood).

(06 Nov '15, 17:18) aseerel4c26 ♦

You can use ogrinfo to look for features in a bounding box as well. Perhaps I will rephrase the answer, but either way this is a more practical way than JOSM. I have perhaps 5-6000 traces (typically several for every day since I started contributing to OSM).

(07 Nov '15, 10:49) SK53 ♦

the josm thing is just handy for a very limited number of repetitions and number of selected traces, yes.

(07 Nov '15, 12:51) aseerel4c26 ♦

QGIS is another route for a limited number of traces

(08 Nov '15, 16:50) SK53 ♦

If you do not need the original file name of the gpx and also do not need the original time stamps, but just the relevant trace itself, then you could use the OSM-Editor JOSM for this:

  1. open JOSM
  2. step 11 needs "expert mode", so activate it. It may be a good idea to disable it afterwards (unless you like to continue to use JOSM's expert interface).
  3. load all gpx files
  4. in the layers dialog: select all layers
  5. rightclick on of the gpx entries in the layers dialog, select "merge"
  6. rightclick the resulting layer, select "convert to data layer"
  7. in the editing map zoom to the location you are interested in and just click one of the tracks (btw: now it is a OSM way) to select it
  8. copy (ctrl+C) the track
  9. create a new layer
  10. paste the copied track (ctrl+V)
  11. export the data layer into a gpx file

note: Please do not "upload" such converted gpx tracks to OSM with JOSM's normal upload feature! Best: restart JOSM before you continue with your normal OSM contributions/editing.

permanent link

answered 04 Nov '15, 19:34

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

edited 06 Nov '15, 05:48

Thanks for this aseerel4c26, that is much appreciated. I will try this.

(05 Nov '15, 05:28) SDavies
3

Have now tried this and it pretty much got me where I want to be, so thanks again.

(05 Nov '15, 22:06) SDavies

@SDavies: thanks for the feedback! :-)

(06 Nov '15, 05:26) aseerel4c26 ♦

Some of the tools listed there https://wiki.openstreetmap.org/wiki/Edit_GPS_tracks may help

permanent link

answered 04 Nov '15, 19:34

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

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:

×255
×235

question asked: 04 Nov '15, 14:40

question was seen: 4,123 times

last updated: 13 Nov '15, 23:16

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