Dear community, i am aware that the topic is discussed on several places - nevertheless i didn't find an answer up to now (sorry when i missed it). My goal is simply to count the total street length of all streets within a certain city (the exact district) for a running project. Two things i can't solve:
Appreciate any help - didn't thought it is so difficult :-O Christoph asked 22 Apr '19, 20:16 KCBCOM |
For a precise result, you cannot hope to cut out "all streets within a city" from OSM before you compute the length, because streets can cross the city boundary and if I understand you correctly, in this case you'd only want the length of the bit inside. One way of getting this done is:
QGIS will also allow you to filter out all roads and clip them at the polygon boundary but it is a more cumbersome and manual process. answered 23 Apr '19, 09:27 Frederik Ramm ♦ |
Thanks for your answer Frederik! After trying your solution it still turned out a little bit complicated for me. So now i came up with following workaround (QGIS 3.6.2):
Step 3+4 are fully described here: http://www.qgistutorials.com/en/docs/calculating_line_lengths.html Greetings - Christoph answered 24 Apr '19, 20:30 KCBCOM |
Yet another possiblity: you can run a query on Overpass API. This one produces a sample statistic for my home town, by value of highway. Length is in meters. This should also point you to the real issues: You should decide for yourself whether you want to count footways and tracks or not. Another source of incertainty are dual carriageways; they would be counted twice because they are two ways in OpenStreetMap. Frontage roads, turn lanes and more may also affect the results. Finally, the request keeps ways on the boundary intact, thus slightly overestimating length values for that part of the problem. Nontheless, for best effort guess data is for sure good enough. answered 26 Apr '19, 18:48 Roland Olbricht |
Have you tried this package? https://github.com/JoaoCarabetta/osm-road-length It is super easy, Install it: pip install osm-road-length And run: import osm_road_length from shapely import wkt geometry = wkt.loads('POLYGON((-43.2958811591311 -22.853167273541693,-43.30961406928735 -23.035275736044728,-43.115980036084224 -23.02010939749927,-43.157178766552974 -22.832917893834313,-43.2958811591311 -22.853167273541693))') length = osm_road_length.get(geometry) answered 30 Apr, 22:29 JOAO LUIZ |