gpx2svg
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.
Usage
gpx2svg takes the following command line arguments (see also gpx2svg --help
or gpx2svg -h
):
- -i [FILE]
- GPX input file (default: read from STDIN)
- -o [FILE]
- SVG output file (default: write to STDOUT)
- -p {mercator,wgs84}
- Projection to use. The default setting is "mercator"
- -m [PIXELS]
- Maximum width or height of the SVG output in pixels (default: 3000). Can't be used together with the "-s" switch
- -s SCALE
- Scale factor for the WGS84 projection. When this is set, the output will be in mm instead of px, with 1 mm representing SCALE mm of the original data (e. g. a value of 1000 will produce an SVG file with 1 mm representing 1 m). Can't be used together with the "-m" switch
- -d
- Drop single points (default: draw a circle with 1px diameter)
- -r
- "Raw" conversion: Create one SVG path per track segment, don't try to combine paths that end with the starting point of another path
- -j
- 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
Examples
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.
Getting involved
The code is managed using Git and can be found on GitLab at https://gitlab.com/l3u/gpx2svg/.
Download
Current release:
gpx2svg-0.2.0.tar.xz
23.2 KB, released: 2021-09-05
Signature file: | gpx2svg-0.2.0.tar.xz.asc | |
---|---|---|
Checksums: | MD5: | 39b6ce2dfd1de98dc139e4c4baaf301c |
SHA1: | 6f9f6be45109080a22301c07de087e4c79841e8c | |
SHA256: | fa8d8ea54dbe6e3d44885565569dd8041b2edb575ae83d400c13a7fe72a76f27 |
Past releases
gpx2svg-0.1.5.tar.xz | | 10.7 KB | | 2018-07-23 | Signature file | | Checksums |
gpx2svg-0.1.4.tar.gz | | 11.1 KB | | 2015-01-04 | ||
gpx2svg-0.1.3.tar.gz | | 11.0 KB | | 2014-09-05 | ||
gpx2svg-0.1.2.tar.gz | | 10.6 KB | | 2013-11-07 | ||
gpx2svg-0.1.1.tar.gz | | 10.4 KB | | 2012-08-26 | ||
gpx2svg-0.1.tar.gz | | 9.5 KB | | 2012-08-25 |