More Fun with gpsbabel

Feb 7th, 2006No Comments

Sorry I haven’t posted much in the past week or so. All last week I’ve been in a training class (perhaps more on that later) and this week I’m trying to catch up. And today I was told that the first build of the new release is due next week. Arrgh!

So, anyway, I took some time and mucked more with GPSBabel. The problem: I wanted to get just the Omaha-area caches out of my GPX file that contains everything. I used the county polygon files from the wonderful gpsbabel-data package and came up with this:

gpsbabel -i gpx -f everything.gpx \
-x stack,push,copy \
-x polygon,file="Nebraska/31-055-Douglas-(County).txt" \
-x stack,swap \
-x polygon,file="Nebraska/31-153-Sarpy-(County).txt" \
-x stack,pop,append -o csv -F -

This worked wonderfully for me. But the problem is that the Omaha area covers much more than two counties — it’s more like six. I came up with a solution that I really didn’t like that involved a lot of swapping my uber-list around in memory. I submitted it to the gpsbabel-misc and someone suggested a different version: take the everything list, take out all one caches not in the counties (i.e. “exclude”) and then toss out all duplicates. Brilliant! His version read the uber-list twice. I made one that popped a copy to the stack and popped back at the end:

gpsbabel -i gpx -f everything.gpx \
-x stack,push,copy \
-x polygon,file="Nebraska/31-055-Douglas-(County).txt",exclude \
-x polygon,file="Nebraska/31-177-Washington-(County).txt",exclude \
-x polygon,file="Nebraska/31-153-Sarpy-(County).txt",exclude \
-x polygon,file="Nebraska/31-155-Saunders-(County).txt",exclude \
-x stack,pop,append \
-x duplicate,shortname,all \
-o csv -F -

(No, I don’t have the Iowa counties in next. I soon will.)

Leave a Reply

You must be logged in to post a comment.