Raster analysis can enable very powerful and large scale analysis. It is especially useful in different environmental applications to detect land use change, mapping and modelling species distribution, mapping suitable locations for either different spieces or solar power parks.
In this task, you will analyse forest change in Estonia and whether protected species Lanius collurio habitats are affected by forest change or not.
The tutorial consists of the following steps:
1. Download data
Please download the forest loss data: Hansen_GFC_2023_lossyear_60N_020E.tif and Estonian borders estonia.gpkg. For the second part download bird species Lanius collurio data lanius_collurio.gpkg
Note
Global Forest Change is based on time-series analysis of Landsat images characterizing forest extent and change globally. Trees are defined as vegetation taller than 5m in height. ‘Forest Cover Loss’ is defined as a stand-replacement disturbance, or a change from a forest to non-forest state, during the period 2000–2023. ‘Forest Loss Year’ is a disaggregation of total ‘Forest Loss’ to annual time scales and the raster value from 1 to 23 indicates loss year from 2001 to 2023 respectively
Data Sources: “Global Forest Change by Hansen et al 2011”, Estonian Land Board and Estonian Environmental Portal (Keskkonnaportaal)
2. Calculating raster area
2.1. Raster clipping
- Open QGIS and in the QGIS Browser Panel, locate the directory where you added the data and add files estonia.gpkg and Hansen_GFC_2023_lossyear_60N_020E.tif to QGIS.
- Save your project with an appropriate name, for example raster_analysis.
- Now lets clip the raster layer with the Estonian boundary to obtain forest cahnge data for only Estonia. Find the tool Clip raster by mask layer in the Processing toolbox and open it. Choose Hansen_GFC_2023_lossyear_60N_020E layer as the Input layer and estonia layer as the Mask layer. Enter 0 as the NoData value. If NoData is determined in raster file then it will not be used in further calculations and will be shown as transparent. In most cases, it is useful to define NoData value.
NoteIn this case, we can set the NoData value to 0 because 0 does not actually exist in the data and it also represents 0 in the original dataset. If the data actually contains the value 0, then 0 should not be used as a NoData value. The NoData value must always be clearly outside the actual data value range, e.g. in this case it could also be 255.
- Raster files can get very big and therefore it is always recommended to use compression. You should always use lossless compression like LZW. To apply compression, choose Low compression in the Advanced Parameters section. Double click on the value box and write LZW. Save the file as forest_est_wgs84.tif and click Run.
- Right-click on the Hansen_GFC_2023_lossyear_60N_020E.tif layer and select Remove Layer.
2.2. Reprojecting raster
- Next we need to reproject the raster layer to the Estonian coordinate system. In the Processing Toolbox search Warp and open it. Choose forest_est_wgs84 as the Input Layer and EPSG:3301 as the Target CRS. In the Advanced Parameters choose Low Compression and LZW like before. Save the file as forest_est_reprojected.tif and click Run.
- Remove the forest_est_wgs84.tif layer. Let’s set the project layer to the Estonian coordinate system. Click on forest_est_reprojected.tif layer and choose
Layer CRS ► Set Project CRS from Layer.
2.3. Styling raster
- Now let’s change the symbology of the raster layer to a more suitable one. Double click on the layer forest_est_reprojected to open
Symbology. Choose Singleband pseudocolor as the Render type, Equal Interval as the mode and 23 classes. Also choose a color ramp to your liking (for example Viridis). Then click OK.
- For better visualization move the layer estonia to the bottom and change it to black.
- Next we’ll add roads and settlements, which we’ll get via WMS. Click
Layer ► Add Later ► Add WMS/WMTS Layer.... In the new window clickNewand then write Maa-amet as the name and copy this link (https://kaart.maaamet.ee/wms/alus?) as the URL.
NoteWMS (Web Map Service) is a service based on OGC WMS (Open Geospatial Consortium Web Map Service) standard that enables displaying spatially referenced data on the computer screen without downloading . Many governmental agencies provide their data using WMS services. Estonian Land Board provideas a lot of free spatial data via WMS: https://geoportaal.maaamet.ee/eng/services/public-wms-wfs-p346.html
- Now click
Connectand choose the layers with ID numbers 138, 139 and 140. Make sure to check the option to Load as separate layers and then clickAdd.
2.4. Calculating areas
- Now let’s calculate the area for each forest change class (i.e. year of change). Find the tool Raster layer unique values report in the Processing Toolbox and open it. Choose forest_est_reprojected as the Input layer. Save the file as class_areas.gpkg and click Run.
- Right-click on the class_areas.gpkg layer and open the Attribute Table. The column m2 contains the area for each class in square meters which shows how many square meters of forest change took place every year.
- Let’s convert the area to square kilometers. To do that, search Field calculator in the Processing Toolbox and open it. Select class_areas as the Input layer. Enter the Field name as area_sqkm and for the result field type choose decimal (double). In the Expression window enter round(“m2” / 1000000, 2). This will convert the square meters to square kilometers. Save the file as class_area_sqkm.xlsx and click Run.
3. Sampling raster data to points
- Our goal is to see how many habitats of the red-backed shrike (Lanius collurio) are affected by forest change (in Estonia it is in most cases caused by logging). First add the layer lanius_collurio.gpkg to the map. The layer contains identified habitats of red-backed shrike in Estonia.
- Then search ‘Sample raster values’ in the Processing Toolbox and open it. Add lanius_collurio as the Input layer and forest_est_reprojected as the Raster layer. For the output column prefix write forest_loss_. Then save the file as lanius_collurio_forest_loss.gpkg and click Run. This will collect values from raster to the points.
- Next open the attribute table of lanius_collurio_forest_loss. As you can see there is a new column called forest_loss_1. NULL means that there was no forest change (in the raster it had NoData) and the number means that there was (the number shows which year the change took place).
- Now we’ll count how many habitat points had forest change. Find the tool Basic statistics for fields in the Processing Toolbox and open it. Choose lanius_collurio_forest_loss as the Input layer and forest_loss_1 as the field to calculate statistics on. To see the results, double click on Statistics in the Results Viewer.
- Count shows how many points (rows) had a value (aka how many points were affected by forest change) and NULL means there was no forest change.