Finding a point of Inaccessibility using QGIS and FOSS tools

Finding points of inaccessibility

Question : What is the point on the Scottish mainland which is furthest from a building (as the crow flies)? This is something called a point of inaccessibility

This is something that is possible to do with rasters, in particular the gdal_proximity tool.

This was done using QGIS 2.18.10

Data sources

I used Ordnance Survey Open Data for this. In particular, a shapefile courtesy of Alasdair Rae. This has all building outlines clipped to the border. I recommend getting this into sqlite or postgres before attempting further processing - it'll save hours of processing time ;-)

Also used a sqlite database with an outline of Scotland for clipping. I created this a long time ago, using data from openstreetmapdata.com, namely the split land polygons, and dissolved them. This is optional, but recommended, as most of the furthest points from buildings are in the North Sea. You could also use Natural Earth data 1:10 admin level 1 for this... the coastline is much coarser, though.

Process

Throughout, I've used EPSG:27700, the standard UTM projection for the UK, in meters.

1. shp2pgsql to load buildings into Postgres table

2. Get centroid layer using DB Manager. This took 4 secs; I gave up on the Shapefile after 5 minutes when it hadn't even got around to 1% done :-) The "1 as one" field will be used later, it is needed!

select st_centroid(geom) as geometry, 1 as one from buildings;

3. Save layer as a permanent OGR source (I used .sqlite). This is needed as the following step doesn't (currently) work with virtual layers.

4. Rasterise to 100m resolution grid. By using the "one" field, all 100x100m cells with a building take the value 1, and all other cells are 0. (I could also use the -burn option instead)

Dundee and environs, as a binary raster:-

 Dundee, with 100x100 cells. Cells with buildings are white.

Dundee, with 100x100 cells. Cells with buildings are white.

5. Proximity. We want to find the distance to the nearest "one" pixel.

gdal_proximity.py /tmp/raster100m.tiff /tmp/proximity100m.tiff -values 1 -distunits GEO -of GTiff

if all goes well, we should see something like this:-

 proximity raster

proximity raster

6. Clip proximity to a cutline so that sea pixels are set to 0

gdalwarp -q -cutline /tmp/scotland_dissolved.sqlite -tr 100.0 100.0 -of GTiff /tmp/proximity100m.tiff /tmp/proximity100m_clipped.tiff

7. Contourise (Extraction > Contours) using 200 meter spacing.

8. Use rule-based rendering to hide contours less than 6km from a building. This instantly shows candidates - only a handful of areas of the mainland (and several remote uninhabited islands) show up.

This image shows contour lines > 6.6 km from the nearest building:-

 areas more than 6600 meters from a building

areas more than 6600 meters from a building

And the winner is...

I make the point of inaccessibility somewhere around OS grid square NN8682, which is ~ 7150m away from the nearest 3 buildings. The limited resolution of the grid (100m) rules out anything more accurate than that :) According to the Lat Lon tools plugin the coords are approximately latitude 56.9211, longitude -3.8661 (rounded down to reflect lack of accuracy)

This is close just to the NW of Beinn Bhreac

 it's in the Cairngorms, there's a surprise :-)

it's in the Cairngorms, there's a surprise :-)

To get the circle, I used a single point layer in 27700, and used a Geometry Generator symbol using

buffer($geometry,7150)

Other reading

This came out of asking a question on GIS Stackexchange.

One feature of these points is that the lie on the intersection points of the voronoi mesh, which provides another technique for finding maxima. In this case the number of points was quite high (300k+) so I decide to go for a more pragmatic approach :)