Tuesday, 30 April 2013


And so back to the question that started me off on all this: hedgerows

There's a long history behind hedgerows. Some field boundaries are thought to date back to the bronze age (or even before); the pattern of some Anglo-Saxon fields has hardly changed since; there are field boundaries that were originally laid out in medieval times.

Hedgerows in these cases are described as "ancient".

However, the busiest period of hedge building in the UK was during the enclosures of common land between 1720 and 1840. This is estimated to have created about 200,000 miles of hedges. By the middle of the 19th century around half of all hedges must have been created by this process. Since then hedgerows have tended to disappear. There has been little large-scale planting since World War One, and developments in farming since the middle of the 20th century mean that perhaps a quarter of hedgerows have since been removed - though the rate of attrition now seems to have slowed.

The bottom line is that a substantial proportion of existing hedgerows in Britain must have originally been laid out in the late 18th and early 19th century.

The best estimate I have found of what is left dates from about twenty years ago. It says there were then about 300,000 miles of hedges across the UK. In absence of anything better, I'm going to assume that the figure is much the same now. Let's call it 500,000 km.

Roughly 17,000km of hedges have been added to OSM. About 3% of those are in residential, commercial or industrial areas, so they don't really count for this purpose. About 11% are definitely rural (based on land use tagging), but there's no obvious way to judge the type of land use for the other 86%. I'm guessing that it's mostly rural. That suggests that about 16,000km of hedgerows in OSM are in rural areas. They amount to roughly 3% of the total we should expect to find. That's not high coverage, but it's fairly typical for features receiving relatively little attention in OSM, and it's enough to start playing around with.

A normal hedgerow will encircle a field, and fields are all sorts of different shapes and sizes. At first I thought that in aggregate there should be roughly equal lengths of hedge heading in every possible direction. But then I heard that (all else being equal) farmers would tend to lay out hedges to keep any shadows cast on their crops to a minimum. To quote a Victorian farming manual:

"Should a field, or a number of fields, require laying off anew, the North and South fences should run due North and South for the purpose of giving the ridges an equal advantage of the sun both forenoon and afternoon".

Things are never quite as simple as the theory, but in a really simple world, we should expect fields to be aligned with the points of the compass, and longer in the north-south direction.

Quite a lot of our local field patterns date from enclosure, and the largest and flattest fields do seem to be aligned with the compass, and longer in a north-south direction than they are east to west.

Looking nationally, according to what has been plotted in OSM (for the British Isles), field boundaries do tend to run "horizontally" in a broadly East-West direction, or "vertically", in a broadly North-South direction. This is true for hedges, fences and walls. I have to admit that I don't see much evidence here that fields tend to be longer in a north-south direction than they are in an east-west direction.

In reality, of course, many hedges follow natural features, such as streams or the slope of hills; and many follow man-made features such as roads or paths. It would only be in a fairly featureless landscape that landowners had a free choice where to lay out their field boundaries. The relationships between a field boundary, and man-made features is likely to have a particularly complex history.

But lets suppose for a moment, that there were enough landowners who were free to chose where they built field boundaries, and that the result still shows up in the data. We might expect landowners to follow the advice above, and try to align the left and right side of fields as closely as possible to due north, so that  shadows on the crops were minimised. There is probable a case for keeping fields more or less rectangular, but the case for aligning the north and south boundaries of a field with due east and west would be weaker. So they would be more inclined to follow natural and existing man-made features. The boundaries would be seem to be oriented more randomly, because they were shaped by other considerations..

When I look at the distribution of orientations around the main compass points, I'm not even sure I can see evidence that the fall of the sun might have had an effect on the direction of north / south field boundaries. The spread around the North-South axis seems similar to the spread around the East-West axis.

So there we are. Field boundaries tend to be aligned with the main points of the compass, but beyond that there is little here to suggest that the fall of the sun has much effect.

I should, of course, point out that the data I am using includes quite a lot of noise. For simplicity I'm not including quite of a lot of data that might be relevant (traces that mark the outline of a field, but omit the type of barrier, for example). And although they don't make up a huge proportion of the total, it would probably be better to eliminate boundaries in in urban areas, which shouldn't count as field boundaries.

There are also quirks in the way mappers choose which data should be plotted. For example (from inspection), it looks to me as though field boundaries that don't follow the edge of a road are more likely to be plotted than field boundaries which do. This might affect the results.

So it's all very speculative. Nevertheless, it's provided an interesting diversion: for me, ,and I hope for others.


By the way, more "horizontal" hedges in OSM were drawn from west to east than from east to west, but obviously there is no inherent direction implied here. Contributors must just be more likely to draw "horizontal hedges "rightwards". They don't seem to have a similar preference between drawing "vertical" hedges "upwards" (from south to north) or "downwards" (north to south).

Road alignments revisited

Here is the plot of road orientations in the British Isles, with the earlier problem with projection fixed.

As before, mappers seem to have a preference for tracing roads in a West-to-East direction. There also seems to be a preference among highway engineers for building roads along the main points of the compass, and a tendency to avoid roads at 45 degrees to the main points of the compass. The pattern is similar for all types of road.

With the exception of motorways, there is also a bit of a bulge at around 70 degree east of due north. I can't see why that should be, but given the volume of data that underlies this, it's unlikely to be a fluke, so there should be some rational explanation.

In the previous discussion there was a suggestion that mappers might provide more detailed traces for roads running horizontally (East-West, rather than North-South) but I can't see evidence of that in the data. The average length of road segments is much the same for all directions.

Anyway, for what it's worth, there it is. Not as interesting as the graph that had a fundamental error in it (unfortunately) - but hopefully a bit closer to reality.

Monday, 29 April 2013

Building alignments revised


With thanks for all the help, and apologies for causing confusion, I now have a more sensible view of how buildings are aligned in OSM, at least for the British Isles. The main puzzle is solved, and of course it was all my own fault. I had realised that I had to re-project the data to get sensible estimates of way lengths, but I hadn't realised that I needed to do the same to get to the orientation. Of course it is blindingly obvious with hindsight, but at the time....  

Now that is fixed, the distribution looks more sensible to me. 

It is still showing spikes on the four main points of the compass, and a smaller cluster rotated about 30% anti-clockwise. Whether that is how buildings are actually oriented is another question altogether. I haven't managed to extract the source for most of these outlines, but about 3% of them say they are traced from OS Open Data, and about 1.5% from Bing. All show similar characteristics.

Now a similar analysis is grinding through for roads, and I will post the results when I get them, in case anyone is still interested.

What is going on here? ...continued

Thanks for the interesting responses to the last past.

I'm inclined to think that the most plausible explanations are that the "spikes" are artefacts, and that most of the effect I am seeing are due to aligning buildings so they capture the sun.

However, I'm not sure it can be as simple as that.

Here is a similar plot based on the alignment of different types of road in the British Isles. The characteristics are similar to buildings: a bias towards East-West orientation, and spikes at the main points. There also seems to be quite a strong tendency for UK mappers to draw roads from West to East, which is quite interesting, but not particularly important. You wouldn't expect the same effect for buildings of course - because they need to be traced all the way round.

We could imagine the travel of the sun affecting both roads and buildings. There might be a link between the alignment of buildings and residential roads, and some other built up roads for example. But I'm not sure this would explain why all the different road types show the same effect.

The bottom line is that I can't convince myself that the travel of the sun is sufficient explanation.

My other concern is that different map projections are having an effect on my calculation of way lengths. But at the moment I can't see what the problem could be. This time I've used ST_Distance_Sphere  to calculate the distance between end points of each straight line, instead of transforming coordinates to OSGB and using ST_Length. I haven't tried ST_Distance_Spheroid yet, but perhaps I should. I understand it is more accurate, but much slower. And surely it wouldn't make enough difference to have this much effect. Or would it?

Sunday, 28 April 2013

What is going on here?

The chart illustrates the alignment of buildings in the OSM database, for the British Isles. The trace of each building was divided into line segments, and the orientation of each segment to due north was calculated. Then the lengths of segment were totalled according to their orientation, and the result plotted as shown above.

If buildings were arranged randomly you would expect the plot to be more-or-less circular: with roughly equal lengths of the building perimeter heading in every direction. Clearly life isn't as simple as that.

What the chart suggests is:

  • A relatively high proportion of buildings are oriented along the main points of the compass: North-South and East-West. Hence the spikes at the top and bottom, left and right.
  • There is a second, smaller, cluster of walls that run roughly 15 degrees (anti-clockwise) off the main points of the compass. Lets say EENE, WWSW
  • There is a tendency to align buildings so that longer walls run roughly East-West and shorter walls run roughly North - South. Hence the oval shape in the chart, with the major axis running horizontally, and the minor axis running vertically.
The question is, why?

Specifically: I loaded an extract of OSM data covering the British Isles into a Postgres / Postgis database. I split ways that define buildings into individual line segments (the straight lines between each node). I calculated the orientation of each line segment using the ST_Azimuth function. All of this was based on the original WGS84 projection. I calculated the length of each segment by transforming the projection to OSGB 1936, and using the ST_Length function to get the length in metres. Totals were summed in the Postgres query, and I plotted the results in Excel. 

For what it's worth, I've tried this with various man-made features (roads, hedges, etc). The east-west orientation seems pretty common. So far I've only found the spikes on the main points of the compass for buildings.