Look up cache information with gpsbabel

Jul 10th, 2006No Comments

I tend search out my geocaches when I get a chance and keep them in a huge GPX file. When I want to get some caches in an area, etc., I use GPSBabel to query that GPX file. Groundspeak keeps tons of useful data and metadata in it’s GPX extensions that I like to have a copy of — if nothing else, I can few it while out in the field withing CacheMate.

The latest problem I had was that I had a list of caches in a CSV file in the format “lat, lon, wptname”. I wanted copy those cache entries from my main GPX file to a new GPX file (that way I can just copy those caches to a CacheMate doc). This could take some serious XML programming, but as I thought about it, I figured that there must be a way with GPSBabel. Here is what I came up with. Note that it is an assumption that the caches in the CSV file are a strict subset of the caches in the GPX file:

  1. Load master GPX file
  2. Push a copy of the GPX file on the stack
  3. Load the CSV file
  4. Filter out all the duplicates. Note that this will leave you with just the caches that aren’t in your CSV file.
  5. Pop the stack and append it to current list
  6. Again, filter out all duplicates. Note that now you will have just the caches that were in the CSV file.
  7. Write the GPX file

Yes, this is a takes a little to get your brain around, but it works well. Here is the GPSBabel call that did it:

gpsbabel -i gpx -f everything.gpx \
-x stack,push,copy \
-i csv -f goodcaches.csv \
-x duplicates,shortname, all \
-x stack,pop,append
-x duplicates,shortname, all \
-o gpx -F goodcaches.gpx

Leave a Reply

You must be logged in to post a comment.