How straight or bendy are the roads?

Where in the world has the straightest roads?

Using OpenStreetMap (OSM) data, I was able to see how bendy or straight the roads are all over the world. One theory I had was that Europe, where current roads are based on older roads that predate cars, would have more bends and curves than the USA, where current roads were (in many places) only put in in the last 150 → 100 years, and probably put in directly and dead straight.

Results

The Mid-west USA and Canadian prairies have the most straight roads. Nearly all of the roads there are straight. This broadly matches my theory.

Netherlands is very straight, but I'm not sure if that's because the Netherlands is just very flat, or due to the "way splitting" inaccuracy incorrectly reporting it as straight.

Measure the bendyness of a road

For all the highway's in OpenStreetMap, the 'bendyness ratio' is calculated as the length of the road divided by the straight line difference between it's end points. A dead straight road will have a ratio of 1.0, and the more bendy the road, the higher the ratio.

The I split the world into little boxes, and measured all the roads that were within that box. A road was considered 'straight' if the ratio was below 1.001, so this includes dead straight, and almost straight roads. The percentage of roads in the box which were straight (weighted by how long the road is), is considered the bendyness of that box. That's the colour in the above map.

Flaws and inaccuracies with this approach

Incompletness

Obvious one: OpenStreetMap is not complete yet, and is missing many roads that exist in the real world.

Roads in many boxes

In order to speed up the SQL query, it counts the enterity of a way (incl it's ratio) in the bbox's results if any part of the way is in the bbox. This means a very long way that passed through 2 (or more) bboxes will be counted twice.

Roads split into 2

It treats each single way element as a different road. If a way is split (into 2 ways) these will then count separately and one road that's very bendy, will appear as several less bendy roads. (e.g.: this way http://www.openstreetmap.org/?way=72436076 ). As an extreme example of this '2 element' ways, which will obviously count as perfectly straight roads. Ways in OSM are often split, not because they are separate roads, but due to how OSM stores data. To solve this, one needs a way to merge connecting ways together.

One approach to merge ways together to get 'real roads', is to merge ways whose endpoints touch if they have the same 'ref'. The ref(erence) of a road (e.g. "N1"), will often show you what is the "natural course of the road", as decided by local planners. Refs, unlike names, often have very little symbolic or sentimental connection, so local road planners are able to assign them much more freely, giving more accurate results. Here in Ireland, it's not uncommon for one long 'real road' to change names at arbitrary junctions.

Source code

The source code I used to generate is on Github: openstreetmap-bendy-roads.

Tools used

I used Osmosis to extract and slim down the original OpenStreetMap planet dump, and imported that into PostGIS with osm2pgsql. I used my own python script to create (in postgres) a new table with the results. Initially I used Quantum GIS (aka QGis) to explore the results, pick the right metric to use, and generate the colour scheme and how to split the data. The boxes were split using Jenks natural breaks classification method. After I had the right data to display, TileMill (which uses Mapnik) was used to generate the tiles in a MBTiles format. I used mbutil (again from MapBox) to split that mbtiles file into directory of tile images that can be uploaded to a dumb web server. The map on this page uses Leaflet to display on this page.

Licence

The map on this page is Copyright © 2013 Rory McCann, released under a Creative Commons Attribution-ShareAlike 3.0 Unported (CC-BY-SA) licence. Made using open licensed (ODbL) data from OpenStreetMap (© OpenStreetMap contributors).