[OSM-dev] planet analysis

Robert (Jamie) Munro rjmunro at arjam.net
Wed Jan 17 12:07:05 GMT 2007

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?

What do you define as road? Does the script have to ignore footpaths and
area features? Also does it have to detect dual carriageways and only
count half of them?

To do a total length of all segments, all you need is an sql query
something like:

select KM_TO_MI(sum(DISTANCE(a.Lon,a.Lat,b.Lon,b.Lat))
 from current_segments
 inner join current_nodes as a on a.id=current_segments.node_a
 inner join current_nodes as b on b.id=current_segments.node_b

(with the DISTANCE and KM_TO_MI functions coming from
http://empyrean.lib.ndsu.nodak.edu/~nem/mysql/udf/, which is the first
library I found that does it).

Robert (Jamie) Munro

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: signature.asc
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070117/276b83f4/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070117/276b83f4/attachment.pgp>

More information about the dev mailing list