Author: Claudiu Forgaci
Software: QGIS 3.24.0-Tisler
All input data were reprojected to the CRS EPSG:3035.
Bounding box coordinates (Format: Lng / Lat, GDAL):
3500000.0000000000000000,2680000.0000000000000000 : 4490000.0000000000000000,3670000.0000000000000000
Start by importing the two layers into QGIS: CLC2018 and the EEA reference grid of 10x10km. Both layers should be in the CRS EPSG:3035 - ETRS89-extended / LAEA Europe.
Examine the attribute table of the CLC layer. Search for a field (column name in the attribute table) called Code_18
. This field should contain values from the 44 Level-3 land cover codes (see the CLC User Manual for details). For a regional-level analysis, we only need the Level-1 codes, which are five classes in total. The Level-1 code is the first digit of the Level-3 code. To get that value, we will create a new column using the field calculator with the following values:
After we have the Level-1 code in a separate column, we dissolve the CLC2018 layer by Level-1 class. This will give us 5 classes, instead of the original 44 classes grouped in a three-level hierarchy. If a higher level of detail is desired, one can work with Level 2 or Level 3 classes. The result is a layer with five rows in the attribute table, each corresponding to a CLC Level 1 class. Use the Vector > Geoprocessing Tools > Dissolve...
tool to dissolve the layer containing the CLC data. Select Level-1
as the dissolving field.
When trying to run the tool in Step 1, it is likely that the CLC layer has invalid geometries and throws an error. Steps to overcome that issue:
1.a. To check if the layer has invalid geometries, run the Check validity
too from the processing toolbox with the GEOS
method selected. The tool generates three layers: Valid output
, Invalid output
, and Error output
. Invalid output
and Error output
will show the invalid geometry and describe the type of error, respectively. Note that this step is informative, so you should not use its output for the next step.
1.b. Use the Fix geometries
tool from the processing toolbox with the CLC layer as input and either create a temporary file or save the resulting layer as a separate shapefile in your file system.
1.c. Re-run the dissolve operation using the layer with fixed geometries as input.
Intersect the dissolved layer with the grid layer using Vector > Geoprocessing Tools > Intersection...
.
Using the field calculator on the intersection layer, calculate the area of each resulting polygon:
Generate points from the polygons with
Vector > Geometry Tools > Centroids...
.
Join the points to the original grid with
Data Management Tools > Join Attributes by Location...
.
Install the plug-in Dissolve with stats.