[OSM-dev] planet analysis
frederik at remote.org
Mon Apr 2 12:35:55 BST 2007
returning to this rather old topic:
> Just committed a script to svn:
> This reads an OSM XML file named data.osm and spits out a file
> length.osm which is the same data with added attributes for the
> of segments and ways calculated by the haversine formula. You can use
> that to then add up lengths of ways with certain tags in a second
> (All lengths in meters).
> It also adds up all lengths for tags with key highway (tag value
> matter) and prints it at the end of the run on STDERR.
> This is done in perl and it is rather slow. It needs about a minute
> for the
> city of Karlsruhe where I live and tells me we have 786km.
I have re-implemented, or "hacked" if you will, this to use regular
expressions instead of a SAX parser. The resulting script is faster
by a factor of about 50 and processes the whole of Germany (that's a
10% share of the planet file) in less than a minute - with all the
disadvantages of not properly parsing XML of course, i.e. if the
planet file layout changes, it will break.
It reads from stdin and writes the augmented XML to stdout, and in
stderr you'll get sums for every type of highway.
My version is here:
Frederik Ramm ## eMail frederik at remote.org ## N49°00.09' E008°23.33'
More information about the dev