Following Dad on the PCT

Every evening I get an email from my dad’s SPOT Satellite Messenger letting me know his latitude and longitude along the Pacific Crest Trail (and that he’s OK). He asked me to track his mileage, so at first I put his coordinates into Google Maps, which actually has the PCT plotted, but the mileages didn’t seem to match the “official” mile markers that he’s referencing from Halfmile. They offer a KMZ file of the PCT for Google Earth, but I totally failed at getting it installed on Ubuntu. Eventually I was able to commandeer Stephanie’s Mac to get it to work, but it seemed like a hassle when all I really wanted was a quick way to enter his current latitude and longitude from the email and find out what half-mile marker he’s the closest to.

Mile 156 of the PCT on Google Earth
The PCT on Google Earth

So of course I decided to write a quick Python program! I unzipped the KMZ file to read the uncompressed 11.9MB KML file within, I figured out how to extract the half-mile waypoints and their coordinates, and I ripped a haversine equation off the web to calculate the distance between any two latitude-longitude coordinates. I didn’t bother with optimization; each time the program runs, it calculates the distance from all the waypoints (there are only 5338) to his current position, and then returns the one that’s closest. Tonight, after 8 days on the trail, it says he’s sleeping near mile 156:

./pct-search.py 33.59556,-116.57129
0156 33.59643,-116.57026 0.1mi

Here’s the code for anyone who’s interested. It just requires downloading the KMZ file from Halfmile, unzipping it, and putting it in the same directory as the script. Itch, scratched.

5 Comments

Hi Justin, thought I’d chime in for once after reading your blog for, oh, maybe three years now. Was interested to see your sidebar link to your Dad’s blog, and have been following him along the trail too. (Love his detailed gear list spreadsheet – I’ve been putting one together just like it! Is he slightly OCD like me?!) -Tony

Hey Tony, thanks for leaving a comment. He’s been planning this trip for at least a year now, but I think his organization definitely springs from the engineer in him. I’m overwhelmed just looking at his mail drop list.

Ha! I was wondering if he was an engineer! I am.. and EVERYTHING MUST BE ITEMISED.

Danny’s been plotting a PCT hike someday (before he’s 40?) and just read/ was very inspired by your Dad’s PDF last night… need to peruse all your posts around PCT for tips/ help. DD may want to borrow your python program… wondering whether, once set up, it might be easy(?) for a nonengineer to use?

Claudine, ha! Or, oh dear? I’m sure my Dad would be more than happy to offer Danny any assistance/advice he might require. He’s also putting together a book chronicling his hike, we’ll share it with you both when he finishes it.

As for the code I used to track his location, no python programming experience is required, it can very easily be set up as a webform, as you can see here: http://justinsomnia.org/pct-search/

I put my initial command line code up on GitHub and then when my Dad came back, he added all the other miscellaneous code I used to map his location, as well as the web form above.

Name

Email (optional)

Blog (optional)