Monday, 19 August 2013

Visibility of Wind Farms


There is much discussion of how wind farms are affecting views of the landscape.

I suspect I'm in a similar position to many people. I like the idea of renewable energy. I don't want to see some fine landscape trashed. I know enough about it to realise that these positions are not entirely compatible. I don't know enough about it to understand how the conflict can be resolved in practice. However, I do think it's important to have the debate . 

So I was particularly struck recently by pictures of Dunstanburgh Castle, taken from the sea, which show Middle Moor Wind Farm looming over the iconic ruins. We walk along the coastal path here fairly regularly, and I hadn't noticed the turbines myself, so I thought I needed to explore a bit more. As the above map shows, the reason I hadn't noticed the turbines was that they are not visible from the coastal path, though they are from further inland, and, of course, from out to sea.

I'm not qualified to enter into a debate on the benefits of wind farms, or where they should be sited, but it does seems to me that a lot of people might find it useful to plot the degree to which they are visible. Some might want to find and visit beautiful landscapes that aren't affected by wind farms, some might want to highlight particularly bad examples as part of a campaign, and some might want to understand what effect different proposals are going to have. 

This is how I went about it:
  • You will need a copy of Quantum GIS, which is available here. To be honest you also need to be reasonably familiar with how to use QGIS. Plotting the visibility of wind farms probably isn't the best place to start. So if all of this is completely new, it might be a good idea to get experience with QGIS, or to get help before proceeding much further.
  • You will need some background maps for positioning everything. I used the QGIS OpenLayers plugin to apply a base Open Street Map layer in order to get myself started. For the image above I have replaced this with the full colour raster version of OS VectorMap District from OS OpenData
  • You will need to know the location and the height (above ground level) of the wind turbines, and you need elevation data for the surrounding area. For elevation I used the OS Terrain 50 elevation data from OS OpenData
  • You need the "Visibility" Plugin for QGIS, which is available on the "contributed" repository - here. You obtain and install this from the Plugins->Manage Plugins menu. 
First, install the Visibility plugin, unpack and organise all the bits and pieces that you have collected, and get yourself positioned in the right general area in QGIS. I don't think this is essential, but things seemed to go more smoothly if I used OSGB projection for everything (27700) since this is what all the OS data uses.

Create a single elevation layer from the various tiles provided with  Terrain50. The Raster->Miscellaneous->Merge menu guides you through the process, and I used Raster->Extraction->Clipper to trim down the area a bit, which speeds up the subsequent analysis. It's useful at this stage to set transparency on this layer quite high, so that you can see the underlying map when you get to the next stage. Personally I also found it useful to stretch the grey-scale on this layer to get some idea of the shape of the terrain, but this isn't essential to the process, and I didn't use it in the final map. 

Initiate the analysis, using the Plugins->Visibility menu. This asks for the position of the viewpoint (i.e. where the wind farm is, in this case). You do this by pointing and clicking on the map. You will also need to enter the height of the masts. What you are actually plotting here is which parts of the ground surface are visible from the top of a mast. What we really want to know is where a substantial chunk of the mast is visible to walker or cyclist (at eye level), from inside a vehicle, or from a bedroom window. I don't know what best practice is for determining the height in these circumstances. In the plot above I've used the total height to the tip of the blades as a "worst case", and 50% of that as a "normal case", then I plotted the two layers with different colours to give some indication of how much variation there is. My guess is that I'me being a little harsh, but not too far away from what most people would expect.

The final step was to set the properties of the different overlays so that areas with no visibility are completely transparent, while areas that we think have visibility of the wind turbines are both brightly coloured, and partially transparent. 

All this seems to work reasonably well over a fairly broad landscape. At a more local level, trees and buildings rather confuse the picture. I wouldn't want to get into an argument about what is visible from where without actually going and having a look on the ground. But at least this gives some indications of what to expect, and it might save a lot of wandering about.

And finally, I've just been figuring this out as I went along - so any suggestions of how to improve the process would be very welcome.

Thursday, 27 June 2013

Looking at where photos are taken

The photographs that we take tell a story about where we have been, what caught our eye, and the memories we want to keep and share with others. 

Photo sharing web sites, such as Flickr, hold a considerable amount of information about the pictures that have been taken in a particular area. Looking at where others chose to record their visit could help us to plan ours. If the information says anything about the experience of visitors then it might even inform discussion on how to promote tourism, or identify priorities for helping visitors to get the most out of their visit.

I've been experimenting with different ways of looking at location information from photographs across a variety of different  places. Here's an example for Durham - a city that I used to know well, but which I haven't visited for a while (too long). 


It's no surprise that most activity falls around the well-known features. The river, and bridges attract attention, and some well-known view-points also stand out. Beyond that, it needs more local knowledge to distinguish between less well-known features and anomalies in the data. Looking at the results for my own town, we can see several picturesque locations that are known to locals, but seem to be largely ignored by visitors. There are other features that seem to catch the eye of visitors, but which we tend to take for granted.

If this looks as though it could be interesting, then here's how it was done.

Firstly, I extracted data from Flickr, using the API "photos search" with a suitable bounding box, and a list of "extras" to pull coordinates, and related information. This extracted data for about 28,000 pictures. However, it's pretty obvious that contributors are not always as careful as they might be about recording the correct location of their photograph. You can't eliminate this problem entirely, but it is possible to improve data quality by being a bit selective, and tweaking the process later can help to distinguish between some of the noise and useful information.

Flickr records the precision of the location information that contributors provide. They call it "accuracy", based on the scale of the map that the contributor was using when they marked the position. If they were zoomed into the finest detail, then accuracy is set to 16. If they were trying to position the picture within a wider area, then accuracy is set to a lower number. I ignored any image where the accuracy of the location was less than 15. This doesn't guarantee that the location is accurate, but it does imply that the contributor has gone to the effort of zooming into detail before marking the location. So it eliminates cases where the contributor has taken a rough stab at the location from a map of a large area. 

This still leaves the common problem of contributors who go to the trouble of picking a precise location, then attach a large batch of different images at the same point. Where there was a batch of images from the same contributor at exactly the same location I only used the first image, and discarded the others. That way any clusters are going to be formed either by multiple contributors marking very similar locations, or by the same contributor taking the trouble to mark different locations in close proximity.

By this stage my sample was down to about 1,600 recorded locations. Some of that data is still noise, but much is clustered around real points of interest.

Analysing clusters depends on calculating the distances between points, so I converted latitude and longitude from Flickr to Ordnance Survey Eastings and Northings. That way, distances are calculated in Metres rather than Degrees.

I then fed the data into R so that I had access to a choice of different clustering algorithms. There is a wide selection of these in R, and I experimented with a few, but ended up using DBSCAN. Basically because this seems to work reasonably well with this kind of data. 

It's a bit more complicated than this, but in principle DBSCAN considers two points as being within the same cluster if they are close to each other. You have to define "close together". I did this by trial and error, and ended up setting "epsilon" to 20 metres. If the figure is set too high, points tend to merge into huge clusters. If the figure is too low then you end up artificially distinguishing between small clusters at a level of detail that the data quality doesn't justify. 

In effect the whole approach relies on the assumption that dense clusters of activity are separated by corridors of  less dense "noise". In areas where large features with thinly spread activity are combined with smaller features with dense activity then this approach doesn't work very well. Consider the case of a stately home with large grounds, for example. Even if there is a similar level of activity in both house and gardens, the stately home will tend to appear as a cluster, while the grounds do not because the results are spread over a much larger area, and just end up looking like noise.

The other parameter that DBSCAN needs is a figure for the minimum number of points in a cluster. This has two effects. Firstly it helps to eliminate "noise" in the data. For example, a minimum cluster size of 2 means that any arbitrary freestanding point would not be considered to be part of a cluster. But there is also a side-effect which I suspect is more important with this kind of data. If two "real" clusters come fairly close together, and there is a bit of "noise" between them, they will tend to merge into a single cluster. By setting a reasonable threshold for a cluster size this avoids the risk that a few isolated points form a bridge between two clusters that should really be separate. There is a related issue that occurs in some other areas, but not in Durham. Long, thin clusters of points can occur along a well-known path. Linking all the pieces of path together depends on a fairly consistent line of points, but normally the density of points along a path will vary. Here a low threshold for minimum cluster size can help to avoid things breaking up. Across the centre of Durham the density of activity is quite high and quite consistent, so in this case, using trial and error, I picked a relatively large figure of 5 as the minimum cluster size. 

Finally I loaded the list of points into a Postigs database, and used concave hull to draw the cluster outlines. Then plotted the final result using QGIS.

Suggestions for improvement are welcome.

Tuesday, 30 April 2013

Hedgerows

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.