GIS cookbook

This set of draft instructions will help a moderately techy user to analyse solar potential in a given geographical area. Note that if the area is bigger than a parish or small town the processing time is likely to be longer than overnight on a normal laptop/desktop. Before you start you need to be familiar with QGIS. A quick runthrough of the QGIS tutorial would probably suffice.

Jon did this work on a Macbook – in some ways it might be easier on a Windows or Linux based PC.

The aspiration is to move as many of these steps as possible to an automated process in the future.

0. Set up a QGIS project

If you haven’t already got a project in QGIS, create a new one, setting the map projection to OSGB36 (EPSG:7405).

1. Get LIDAR data

See list of LIDAR surveys

You need to get the relevant  National LiDAR programme DSM files (not the Composite files) for your area of study

Lidar DSM can be downloaded from here

Once downloaded extract the zips and save to somewhere temporary

2. Merge LIDAR data

In QGIS go to the Raster > Miscellaneous > Merge… menu. Next to the Input Files, press the Select… button and select all of the .tif files in the directories. You also need an Output File for the merged data. Finally, tick No data value and set it to -9999.

These steps are informed by the page here

3. visualise DEM

In QGIS add the LIDAR output file you have just made as a layer. Select symbology, render type: hillshade. This just helps to see the layer and make sure it covers the right area

4. Clip DEM to shapefile

Raster|Extraction|Clip Raster by Mask Layer
use shapefile of buildings. TODO : explain where to get these. You can get them from OSM or OS – the later seem better.

* Set CRS explicitly in the dialogue box

* Also assign a specified nodata value of -99999

That last step reduces filesize and processing times.

5. Generate the insolation raster

This is the real processing part. In my installation I could not set up the SAGA tools to work within QGIS so just used them through command line. I installed SAGA with homebrew.

cd /usr/local/opt/osgeo-saga/bin
saga_cmd ta_lighting 2 -GRD_DEM "path to input .tif" -PERIOD 2 -DAY 2019-01-01 -DAY_STOP 2019-12-31 -DAYS_STEP 5 -LOCATION 1 -METHOD 2 -GRD_TOTAL "~Path to output.tif"

-DAYS_STEP change to 5 for real run, 30 for testing. Real run can take so long you need to keep machine from sleepin. On a mac just open a terminal and type:
caffeinate &
Mac will stay awake as long as that terminal is open.

6. apply a factor to change insolation figure to KWh realistic annual PV output.

The scaling factor I used is 0.09, this is derived from comparison with PVGIS:
meteo scaling 0.65 (cloudiness)
pv efficiency 0.16
losses 0.86
In QGIS use Raster Calculator with the following formula:

("TOTAL_INSOLATION@1">1250)*"TOTAL_INSOLATION@1"*0.09

This discards values lower than 1250, and multiplies the rest by scaling factor. The result is a raster with kWh/year for each m2 pixel

[…] TODO possible missing step here?

7. Add attribute to a shapefile for per-building stats

In QGIS Run Zonal Statistics tool (in Processing toolbox) as documented here

8. apply panel density factor

I used a factor of 75% to reduce output based on the need to keep panels away from roof edges. TODO:explain what tool was used here (don’t combine with Raster Calc above, do this at aggregated rooftop level within Shapefile)

9. publish to web page

Results can be made int useful clickable webpage with QGIS 2 web:
Openlayers option seems to work better than Leaflet
to modify opacity if it does not come through edit layers.js ie

var lyr_XXX = new ol.layer.Vector({
opacity: 0.3,

see also:
https://openlayers.org/en/latest/examples/draw-and-modify-features.html
https://stackoverflow.com/questions/33129271/get-coordinates-of-drawn-feature-in-openlayers