[OSM-talk] Statistics on road network length?

Frederik Ramm frederik at remote.org
Sun Nov 20 19:48:06 GMT 2011


Hi,

On 11/18/2011 10:58 PM, Frederik Ramm wrote:
> On Fri, 18 Nov 2011 11:56:53 -0800 (PST)
> ThomasB<toba0211 at yahoo.de>  wrote:
>> not sure we are using the same script. With osmosis --read-pbf
>> file=/home/wicking/osm/germany.osm.pbf --write-xml file=- | perl
>> osm-length-2.pl>  /dev/null
>> I am 15 minutes after the start at 14GB RAM usage and still
>> increasing.
>
> Yes, the osm-length perl script wastes a lot of memory by keeping all
> nodes in a Perl hash. It would be relatively easy to write an efficient
> road length calculator based on the Osmium framework; that one should
> then work with a far smaller memory footprint.

http://www.remote.org/frederik/tmp/osmium_road_length.cpp

Does all of Germany (from a PBF file) in less than 5 minutes and using 
less than 2 GB of RAM. I haven't got the time to do this properly right 
now - it just dumps a list of results for all highway types to stdout 
and sadly includes all the tag rubbish:

*                        0.2km
Access_Ramp              0.0km
Altmarkt                 0.2km
FIXME                    0.8km
Fußweg                  0.0km
Hinterer Spielbach       0.1km
Hohndorfer Weg           1.2km
Privatstraße            0.1km
Sandstraße              0.1km
Weikersdorfer Weg        0.1km
abandoned               23.4km
abandonned               0.3km
abendoned                0.5km
access                   0.8km
access_ramp              0.1km
agriculture              0.8km
almost_path              0.4km
animal_pass              0.1km
animal_trail             0.2km
area:<unterschiedlich>     0.1km
bicycle                  0.1km
bollard                  0.4km
bridge                   0.0km
bridleway             2198.5km
bridleway, track         0.5km
bus_guideway             5.9km
...

(full result file for Germany here: 
http://www.remote.org/frederik/tmp/osmium_road_length.result)

But anyone with minimal C++ skills should be able to polish that. (If 
you do, be so kind and make your polished version available somewhere 
stable, e.g. send it to Jochen for inclusion in his examples directory 
or so.) A power user might even want to take Peter Koerner's history 
splitter which is OSM based and has the ability to cut out OSM data 
along polygon boundaries, and add the length formula from this script so 
you can easily make a separate counting for lots of places.

Best wishes
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00'09" E008°23'33"



More information about the talk mailing list