Josh Butts - Homepage

Convert GPS .loc files to .gpx files with PHP

This is a simple PHP5 script I wrote to convert LOC files from geocaching.com into GPX files.  You have to be a paid member to get GPX files from geocaching.com, but both LOC and GPX files are xml, and are fairly trivial to convert.  I tested that the GPX files produced from this script correctly load into my Garmin desktop software as well as into the GPS.  The script is hard coded to set them to be geocache-type waypoints, but you could always change that as needed.  Of course, I provide no warranty of any sort, but it worked for me. I called this file loc2gpx.php, but you can download the source and call it whatever you like. The example command below assumes you agree with my name for it.

Usage:
Pass the script a folder full of .loc files and it will create a single .gpx file for each one.

[~]$ php loc2gpx.php /path/to/.loc files

Download loc2gpx.php

One Response to “Convert GPS .loc files to .gpx files with PHP”

  1. Kelly says:

    I don’t get it. Sorry for being computer illiterate. How do I use this script? Do I need a program of some sorts?

Leave a Response