Schlagwort-Archive: pfaedle

Adding shapes to GTFS feeds with pfaedle

Headway frequency mapping in R. Requires shapes.txt

Three years ago, I wrote a little piece about how we cleaned up SWU’s GTFS feed.

I nonchalantly added that adding shapes and Conveyal’s GTFS editor would be a topic for another time, but never came around writing about that. I do not use the GTFS editor anymore, but Patrick Brosi’s pfaedle tool is still invaluable if your GTFS feed does not come equipped with a functional shapes.txt.

I had described the problem and where to find the proper tools back in early 2020 right at the intersection of my activism and public administration work. With the regional transit area spanning two Bundeslaender, there are some pitfalls left, however. Hence, a short primer.

Ingredients:

  • One Linux machine, whatever the flavor. Be it a VM or an old Laptop, it hardly matters. It shouldn’t be the slowest available machine, though, and it should come with a decent amount of RAM (the machine I’m using has 8 GiB). And if you go the germany-latest route (see below), about 100 GiB of hard disk space are required.
  • cmake, gcc (>4.9), git, wget, bzip2: sudo apt install cmake gcc git wget bzip2
  1. Get pfaedle, which is pretty much following the steps outlined in the github repo:
git clone --recurse-submodules https://github.com/ad-freiburg/pfaedle
mkdir build && cd build
cmake ..
make -j4
# optionally:
make install

2. Navigate to the folder where you store your unzipped(!) GTFS feed you want to add shapes to.

3. Get the proper OSM files. Since we are working with Ulm and Neu-Ulm, we’d either need a download of the metropolitan area of both cities, or download and merge the extracts for Bavaria and Baden-Wuerttemberg… or download and use the extract for the whole of Germany :shrug:

# Whole of Germany
wget https://download.geofabrik.de/europe/germany-latest.osm.bz2
bunzip2 germany-latest.osm.bz2

# Merge, requires osmium-tool: apt install osmium-tool
wget https://download.geofabrik.de/europe/germany/bayern-latest.osm.bz2
wget https://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.bz2
bunzip2 bayern-latest.osm.bz2 && bunzip2 baden-wuerttemberg-latest.osm.bz2
osmium merge baden-wuerttemberg-latest.osm bayern-latest.osm -o merged.osm

Beware: Unzipping the GTFS feeds takes ages, especially the germany-latest. Expect a file exceeding 70 GiB and quite some decompression time. My laptop takes about 4–5 minutes for each Bundesland to unpack.

All that is left to do now is to let pfaedle do it’s work: pfaedle -D -x merged.osm .
After completion (and again, using it with germany-latest.osm takes quite a lot of time), a new folder gtfs-out is created. Test the results with your usual testing suites, ZIP it up, and off you go.