{"id":154,"date":"2015-01-09T16:28:31","date_gmt":"2015-01-09T16:28:31","guid":{"rendered":"https:\/\/discontinuity.ca\/?p=154"},"modified":"2015-01-09T16:49:56","modified_gmt":"2015-01-09T16:49:56","slug":"diy-guidebook-parsing-osm-data","status":"publish","type":"post","link":"https:\/\/discontinuity.ca\/?p=154","title":{"rendered":"DIY Guidebook – Parsing OSM data"},"content":{"rendered":"

I used the Geofabrik<\/a> package of OpenStreetMap data for Berlin as a basis for several layers in my map. Once I unpackaged the file to a simple .osm, it’s over 700 MB. I did try to open this in QGIS, but… that didn’t work so well.<\/p>\n

Fortunately, you can filter the file before bringing it into your mapping software using osmfilter<\/a>. The OSM wiki<\/a> and\/or the query feature on openstreetmaps.org<\/a> will help you figure out how to filter for what you’re interested in.<\/p>\n

For example: I wanted to grab all the museums that OpenStreetMap knows about. I looked on the OSM wiki for museums. This page<\/a> shows that museums will be labelled with the tag “tourism=museum”. Then I ran this command:<\/p>\n

.\/osmfilter berlin-latest.osm --keep=\"tourism=museum\" -o=museums.osm<\/code><\/p>\n

This runs the osmfilter script (located in the folder in which I’m executing the command) on the berlin-latest.osm. It exports a file museums.osm that includes only those objects with the tag “tourism=museum”.<\/p>\n

I separated the transit information I wanted to import into stations and lines. It’s also divided by operator and type (S-Bahn, U-Bahn, tram, etc). To get the U-Bahn stations, for example, I ran<\/p>\n

.\/osmfilter berlin-latest.osm --keep\"railway=station AND station=subway\" -o=ubahnstations.osm<\/code><\/p>\n

For the tram lines, I ran commands like this:<\/p>\n

.\/osmfilter berlin-latest.osm --keep\"route=tram AND operator=BVG\" -o=trams\/TramWays.osm<\/code><\/p>\n

.\/osmfilter trams\/TramWays.osm --keep\"ref=M1\" -o=trams\/M1.osm<\/code><\/p>\n

I could definitely also have left the tram routes all as one file and done filtering in QGIS to change the colour, but this way seemed easier.<\/p>\n

Here’s how it looks after I import some layers this way:<\/p>\n

\"QGIS<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

I used the Geofabrik package of OpenStreetMap data for Berlin as a basis for several layers in my map. Once I unpackaged the file to a simple .osm, it’s over 700 MB. I did try to open this in QGIS, but… that didn’t work so well.<\/p>\n","protected":false},"author":1,"featured_media":156,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[22,19,28,21],"_links":{"self":[{"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/posts\/154"}],"collection":[{"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154"}],"version-history":[{"count":3,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions\/159"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/discontinuity.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/discontinuity.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}