I haven't been able to find anything that could comprehensively help me with my problem.

I want to calculate median elevation for UK local authority areas. So far I've taken the OS Terrain 50 data which is available in three formats [ESRI ® Shape (Contours): 1.1 Gb], [GML (Contours): 1.1 Gb], [ASCII Grid and GML (Grid): 162 Mb].

I think I need to intersect the height data with the local authority boundaries, but I'm struggling. There are lots of related questions on OS Terrain 50 such as here, here and here but some of them focus on loading in the data in different formats on other operating systems. I'm on Windows 7 and attempting to do this in QGIS. I have limited Python experience, but I suspect I'm going to have rectify that to solve this problem.

How do I load in the very large number of WinZipped files associated with the OS Terrain 50 and then take the intersection with the local authority boundaries, in order for me to calculate basic statistics on the associated elevation attributes?


1 Answer 1


The first thing will be to unzip the OS Terrain 50 zip files to ASC files. You should be able to do this as a batch process (I've forgotten how in Windows). Once you have the individual ASC files probably the easiest thing to do is bring them together in a virtual raster (*.vrt) file: Raster -> Miscellaneous -> Build Virtual Raster (Catalog). Load the resulting *.vrt file into QGIS.

Load your local authority (LA) boundaries polygon layer over the VRT layer and set its fill to 'No Fill', so that you can see what you are doing. Select the LA polygons of interest: View -> Select -> Select Features (hold down the CTRL key to select multiple polygons). Then save the selected features to a new shapefile: Right-click on the layer and 'Save as', remember to tick the 'Save only selected features' box. Make sure all of your selected polygons fit wholly within the area of your DEM.

Load the selected polygons layer, install the 'Zonal Statistics' plug-in and run it: Raster -> Zonal Statistics. In the attached picture the selected boundary polygons are in the 'local_las' layer. The 'Zonal Statistics' plug-in will write the selected descriptive statistics as attributes to this layer. In this case it will be seen, for example, that the median elevation for West Berkshire is 118.40 metres.

enter image description here

  • When I do Build Virtual Raster (Catalog), QGIS is happy with me doing this for a few files. When I try to do it for the entire directory (~2800 asc files) I get the error "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program". Any ideas? Commented Apr 9, 2016 at 23:19
  • 2800-odd ASC files? I think you'll need to break the problem down into smaller chunks. I don't have a problem gathering the ASC DEMs for one 100 km OS grid square into a VRT file, for example, or using it. You could try merging the individual ASC files into one enormous ASC file, if your system can cope with doing this. Raster -> Miscellaneous -> Merge.
    – nhopton
    Commented Apr 10, 2016 at 14:37
  • This worked - thanks nhopton! In the end I used the Consortium for Spatial Information’s (CGIAR-CSI) SRTM 90m Digital Elevation Database v4.1 instead of the OS Terrain 50 because it allowed me to take the whole of the UK in only four raster files, making the Virtual Raster (Catalog) far more straight forward! Commented Apr 12, 2016 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.