notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (43), scripting (13), linux (5), bash (4), geojson (4), obsidian (4), android (3), github (3), html (3), jq (3) ............ see all (+53)

viewing a single note

how to get a GPS trace of train and boat journeys # source

tags: travel, geojson, gpx, maps • 510 'words', 153 secs @ 200wpm

I like sustainable travel. I also like interrailing. I also like maps.

Let's combine all three! This winter I went via train from Sheffield to Hamburg (for Chaos Computer Club), and then on to Lapland, and back.

The map

To skip to the chase, I made a coordinates file of the trip, and you can see it here on a map:

https://geojson.io/#data=data:text/x-url,https%3A%2F%2Fraw.githubusercontent.com%2Falifeee%2Feurope-trips%2Frefs%2Fheads%2Fmain%2F2024-12%2520CCC%2Fall.geojson

It's combined from train journeys, ferry journeys, and bus journeys.

Train data

I got the train routing data in .gpx format from https://brouter.damsy.net/, selecting the "Rail" profile in the dropdown. Then, I clicked close to the stations I went to/from/past, got a nice map that looked alright, and exported it.

Bus data

I also used https://brouter.damsy.net/ for this, after I'd found it was good for trains. I just selected one of the "Car" profiles, and set my waypoints, and exported it in the same way.

Ferry data

This was different, as ferries don't use roads or train tracks [citation needed]. But! They are documented well on mapping services. So, I found the route I wanted on https://www.openstreetmap.org/ (OSM) (e.g., the Liepãja to Travemünde Ferry) by using the little questionmark "query feature" button, then opened it on https://overpass-turbo.eu/ (a website for querying OSM data) by writing the query (with the correct feature ID):

way(128069455); out geom;

Then, I can click "Export" to get the .gpx (or other format) data out.

Combining

I spent a long time trying to figure out how to combine .gpx files with ogrmerge.

However, I couldn't figure it out. .gpx is confusing, and everyone who uses it seems to use GUI tools like arcgis or qgis, while I prefer to be able to do things with a command, which I can then repeat in future.

In the end, I converted the files to .geojson (my one true love) with ogr2ogr file111.geojson file111.gpx tracks for each file, and then combined them. Handily, I'd already written a note about combining .geojson files! I wish I stuck in .geojson the whole time. .gpx gives me headaches.

The End

That's it!

I could then load the combined file into https://geojson.io/ to check all was well (it was, I expected I might have to "reverse" some paths to be "forwards"), and I uploaded it to a new GitHub repository, https://github.com/alifeee/europe-trips/.

I also laser cut a mini Europe with a line for the trip on the map, as a gift for my lover :]

back to top back to main page