gpx2wkt — converts GPX to Well-known Text
To MULTILINESTRING to be more exactly.
Download
- Pre-compiled binary
- Git repository:
git clone http://komar.in/git/gpx2wkt/
(or use github) - Release sources in tarballs
Building
First you need to get:
- an OCaml compiler >= 3.11;
- GNU Make;
- findlib for ocamlfind command;
- extlib for OCaml;
- xmlm for OCaml;
Then simply run
make
sudo make install
Usage
gpx2wkt < /path/to/file.gpx
Example:
% cat example.gpx
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="OpenStreetMap routing service" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<trk>
<trkseg>
<trkpt lon="84.373121" lat="28.236501"></trkpt>
<trkpt lon="84.370658" lat="28.291714"></trkpt>
<trkpt lon="84.400726" lat="28.326931"></trkpt>
<trkpt lon="84.406094" lat="28.355106"></trkpt>
<trkpt lon="84.405869" lat="28.411481"></trkpt>
</trkseg>
</trk>
</gpx>
% gpx2wkt < example.gpx
MULTILINESTRING ((84.373121 28.236501, 84.370658 28.291714, 84.400726 28.326931, 84.406094 28.355106, 84.405869 28.411481))
This tool is heavy used on waypoint.in to import GPX routes into PostGIS.