Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a bunch of GPX files and I want to find out which files contain tracks located in certain geographic extent, e.g. files containing tracks in Pennsylvania. Also, the inverse is also useful too, e.g. any file containing tracks not in USA. How to do this using any command line tool?

Gpsbabel's polygon filter looks like what I want. But for some reason I could not make it work. The filter does not filter anything. I am not sure whether the polygon filter works with track data. This is how I run it:

gpsbabel -i gpx -f infile.gpx -x polygon,file=test_bb.txt -o gpx -F outfile.gpx

Adding exclude suboption to polygon filter does not make any different to the output as well.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I don't know much about gpsbabel, but here are a few examples with OGR: if you just need an approximation, you can use:

ogrinfo -al -so infile.gpx

Which will give you the binding box. Similarly, you can use ogr2ogr to pull out geometries which overlap a spatial extent with -spat:

ogr2ogr -spat xmin ymin xmax ymax filtered.gpx infile.gpx

If binding boxes are insufficient, you could write a Python script which used Shapely's Intersection().

share|improve this answer
    
ogrinfo is just what I need. I eventually used ogrinfo -so infile.gpx -spat xmin ymin xmax ymax | grep 'Extent'. If there are tracks in the given bounding box, the Extent value will be available. –  ejel Mar 4 '11 at 3:23

According to capabilities page gpsbabel's polygon filter only supports waypoints.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.