OpenStreetMap

Hi Today I set out to try to calculate the total length of paths in Sweden. I filtered all “highway=path”s using osmconvert and osmfilter from a dump and got an .osm-file.

Now what?

Script? JOSM?

I tried JOSM which failed because if just 1 of the 91,777 paths is closed JOSM refuses to calculate the length it seems.

Any ideas?

Comment from mmd on 20 November 2019 at 17:21

According to Overpass API, there’s a total of 149813 highway=path ways with a total length of 52521 km in Sweden.

Comment from mmd on 20 November 2019 at 17:23

by the way, here’s the query I used: https://overpass-turbo.eu/s/OhF

Comment from pangoSE on 20 November 2019 at 19:04

Big thanks! I learned something new. I would love to populate wikidata with queries and results like this to ingest statistics about OSM there with regular intervals. Anyone interested in joining in the effort?

What measures are interesting to you?

  • Number of buildings per country?
  • Total distance of trunks?
  • Total distance of paths?
  • Total area of beaches?

Comment from mmd on 20 November 2019 at 19:18

I don’t really know why you would want to add random statistics about OSM to wikidata, those seem fairly random at best. I mean I’m pretty sure there some sites out there crunching OSM planet files and producing some stats on a regular basis. If anyone wants to see those numbers, I would never head for Wikidata and always consult the real source.

Comment from skorasaurus on 23 November 2019 at 19:06

There are many different ways that you could do this and depends on how comfortable you are with particular tools (qgis, postgis, or python libraries).

I did this for my city several years ago - https://skorasaurus.wordpress.com/2014/05/07/how-i-measured-clevelands-length-of-roads-with-postgis-and-osm/

I admit that installing postgis and postgresql can be a bit challenging if you do not have experience with it.

Comment from pangoSE on 16 January 2020 at 11:25

I have improved the query to better catch the type of paths I’m interested in and added it to the examples as a similar example was missing. https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#Count_number_of_ways_and_length Do any of you know how if it is possible to calculate this over time? Say yearly?


Login to leave a comment