{"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 &#8211; Parsing OSM data"},"content":{"rendered":"<p>I used the <a href=\"http:\/\/download.geofabrik.de\/\">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&#8217;s over 700 MB. I did try to open this in QGIS, but&#8230; that didn&#8217;t work so well.<!--more--><\/p>\n<p>Fortunately, you can filter the file before bringing it into your mapping software using <a href=\"http:\/\/wiki.openstreetmap.org\/wiki\/Osmfilter\">osmfilter<\/a>. The <a href=\"http:\/\/wiki.openstreetmap.org\/wiki\/Main_Page\">OSM wiki<\/a> and\/or the query feature on <a href=\"openstreetmaps.org\">openstreetmaps.org<\/a> will help you figure out how to filter for what you&#8217;re interested in.<\/p>\n<p>For example: I wanted to grab all the museums that OpenStreetMap knows about. I looked on the OSM wiki for museums. <a href=\"http:\/\/wiki.openstreetmap.org\/wiki\/Tag:tourism%3Dmuseum\">This page<\/a> shows that museums will be labelled with the tag &#8220;tourism=museum&#8221;. Then I ran this command:<\/p>\n<p><code>.\/osmfilter berlin-latest.osm --keep=\"tourism=museum\" -o=museums.osm<\/code><\/p>\n<p>This runs the osmfilter script (located in the folder in which I&#8217;m executing the command) on the berlin-latest.osm. It exports a file museums.osm that includes only those objects with the tag &#8220;tourism=museum&#8221;.<\/p>\n<p>I separated the transit information I wanted to import into stations and lines. It&#8217;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<p><code>.\/osmfilter berlin-latest.osm --keep\"railway=station AND station=subway\" -o=ubahnstations.osm<\/code><\/p>\n<p>For the tram lines, I ran commands like this:<\/p>\n<p><code>.\/osmfilter berlin-latest.osm --keep\"route=tram AND operator=BVG\" -o=trams\/TramWays.osm<\/code><\/p>\n<p><code>.\/osmfilter trams\/TramWays.osm --keep\"ref=M1\" -o=trams\/M1.osm<\/code><\/p>\n<p>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<p>Here&#8217;s how it looks after I import some layers this way:<\/p>\n<p><a href=\"https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36.png\"><img loading=\"lazy\" class=\"alignnone wp-image-156 size-medium\" src=\"https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-300x169.png\" alt=\"QGIS with imported layers\" width=\"300\" height=\"169\" srcset=\"https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-300x169.png 300w, https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-1024x576.png 1024w, https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-400x225.png 400w, https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-326x183.png 326w, https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36-700x394.png 700w, https:\/\/discontinuity.ca\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-09-at-17.20.36.png 1366w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s over 700 MB. I did try to open this in QGIS, but&#8230; that didn&#8217;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}]}}