[OSM-dev] planet analysis

Jochen Topf jochen at remote.org
Wed Jan 17 15:33:02 GMT 2007


On Wed, Jan 17, 2007 at 10:58:57AM +0000, SteveC wrote:
> I got asked, again, yesterday how many miles of road we have (in the
> UK). Anyone want to write a script against the planet dump to figure it
> out?

Just committed a script to svn:

http://svn.openstreetmap.org/utils/osm-length

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 lengths
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 step.
(All lengths in meters).

It also adds up all lengths for tags with key highway (tag value doesn't
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. The official
statistics tell me that Karlsruhe has 755km of paved roads, so give or
take cycleways, footways, different bounding box and that we still
probably only have half of Karlsruhe that number sounds about right.

I am not running this on the planet file, because this would take a
couple of hours on my machine and it will probably also need too much
memory. The perl script creates hashes of all nodes and all segments and
thats not going to work on the planet file on my machine.

So, have fun with it and feel free to improve/change anything.

Jochen
-- 
Jochen Topf  jochen at remote.org  http://www.remote.org/jochen/  +49-721-388298





More information about the dev mailing list