I am doing data analysis on geographical areas and need the total length of streets/ roads in a map area. How do I do this??

asked 23 Mar '11, 18:39

ajackson's gravatar image

accept rate: 0%

edited 25 Mar '11, 11:51

TomH's gravatar image

TomH ♦♦

permanent link

answered 23 Mar '11, 19:20

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 24%

edited 09 Nov '13, 03:28

amritkarma's gravatar image


you can do this by loading the planetfile (all osm-data) or an extract of it into a database. In OSM we use PostgreSQL with the PostGIS extension. Then you can make queries on the database to get the answers to your questions. To get the downloaded data into your database, there are different solutions available, e.g. osmosis (allowing for a full copy) or osm2pgsql (used to create extracts with only a part of the data according to tags you choose).

If you want to analyze the data and obtain real lengths and areas you should not use the spherical mercator projection (900913) we generally use to render maps, because the results are not real world units in this projection.

permanent link

answered 23 Mar '11, 18:47

dieterdreist's gravatar image

accept rate: 3%

Okay. Lets try this again. I am not familiar with the systems you reference. I am downloading county and state date on crimes, and need to calculate the total length of the streets/ roads in the area for certian calculations. I am not a programmer, atleast not since 1975, and am not famikliar with more recent systems. Is ther a simle wat to get this information?

permanent link

answered 23 Mar '11, 20:11

ajackson's gravatar image

accept rate: 0%


I linked you to several OSM-tools which are described on the pages. If you already have an extract covering exactly the area you want to analyze you can directly use the script Frederik linked above. Otherwise you will have to cut the desired area out of a bigger extract (if it is not very small and you can download it via JOSM). Cutting out of OSM data is usually done with Osmosis. You can download it from svn ( http://svn.openstreetmap.org/applications/utils/osmosis/trunk/ ). Examples and explanations (also for installing/compiling) are in the wiki: http://wiki.openstreetmap.org/wiki/Osmosis

(23 Mar '11, 20:16) dieterdreist

There is no simpler way to get this information. If you happen to have some GIS software at hand that can compute road lengths then you might download a matching shape file for your area of interest from download.geofabrik.de but even that requires that you know your GIS program and invest some time. If you are lucky then you can find someone to do this work for you - but they will have to perform the exact steps we have outlined above and which you are unable or unwilling to perform. A polite request to the mailing list or forum, with details about the areas of interest, 'might' work.

(23 Mar '11, 21:38) Frederik Ramm ♦

Yes, there's a simpler way -- pay a consultant to produce the data for you. You could try the companies listed at http://wiki.openstreetmap.org/wiki/Commercial_OSM_Software_and_Services for a start.

(23 Mar '11, 21:43) Jonathan Ben...

There is a python package that does exactly that:


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)
permanent link

answered 30 Apr, 22:27

JOAO%20LUIZ's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 23 Mar '11, 18:39

question was seen: 18,683 times

last updated: 30 Apr, 22:27

powered by OSQA