gpx2svg does, as the name implies, convert GPX data to SVG data. The Mercator Projection is used to translate the GPS latitude and longitude values to Cartesian coordinates. It's the same projection widely used by different map providers, e. g. OpenStreetMap, Google Maps or Bing Maps and programs that deal with geodata, like GpsPrune, JOSM or Viking.
By default, gpx2svg tries to combine as many track segments as possible to combined paths, so that the output is as usable as possible. If respective content is found, three groups are created: one with all single points, one with all closed paths and one with all open paths.
gpx2svg is written in Python 3 and only uses the standard library without further dependencies. That means you just have to have Python 3 itself installed to be able to use it. Thus, it will most probably not only run on Linux, but also on Windows and Mac.
It's just one single file. No installation or compiling has to be done.
gpx2svg takes the following command line arguments (see also
gpx2svg --help or
- -i [FILE]
- GPX input file (default: read from STDIN)
- -o [FILE]
- SVG output file (default: write to STDOUT)
- -m [PIXELS]
- Maximum width or height of the SVG output in pixels (default: 3000)
- Drop single points (default: draw a circle with 1px diameter)
- "Raw" conversion: Create one SVG path per track segment, don't try to combine paths that end with the starting point of another path
- Join all segments to a big one in the order of the GPX file. This can create an un-scattered path if the default combining algorithm does not work because there are no matching points across segments (implies -r)
An example call to convert the GPX data in gpxfile.gpx to SVG would be:
gpx2svg -i gpxfile.gpx -o gpxfile.svg
Using the standard input and output, you could for example produce a gzipped SVG file from a gzipped GPX file like so:
zcat gpxfile.gpx.gz | gpx2svg | gzip -f > gpxfile.svgz
Here some screenshots. The first one is a GPX file containing the coastline of Iceland (extract from OpenStreetMap) viewed with GpsPrune. The second one shows the unchanged SVG output of gpx2svg viewed with Inkscape and the third one shows the same data with changed border width and filled with a colour (notice that this was possible without joining any nodes :-). Additionally, the paper size had been increased.
The code is managed using Git and can be found on GitLab at https://gitlab.com/l3u/gpx2svg.
Current release: gpx2svg-0.1.5.tar.xz
10,7 KB, released: 23.07.2018