Professional Documents
Culture Documents
gorica.bratic@polimi.it; maria.brovelli@polimi.it
2
Run QGIS with GRASS as Administrator
3
Load vectors (1)
4
Load vectors (2)
5
Load rasters
6
Install QGIS plugins
7
Introduction to supervised classification
8
What is supervised classification?
Supervised classification takes advantage of the training set and classification algorithms to predict the class.
Training set is a set of areas or points in the region of interest for which the class is known (field survey,
photointerpretation, etc.)
Classification algorithm uses training set as input to „learn“ to recognize similar values in the satellite imagery.
10
Training set creation
11
Training set
The training set is a set of land cover class samples for each class expected in the classification output.
Unique guidelines for training set extraction do not exist, and approach for doing so varies depending on:
• Classification algorithm
• Number of classes
• Desired accuracy
• Budget
Often sampling theory is the basis for estimating the suitable sample size that would result in appropriate
characterization of spectral signatures.
In some other cases recommendation is to have a minimum of 10–30p samples per-class for training,
where p is the number of bands used.
For every approach, the training samples must be correct, therefore we must have confident source of
reference information:
• in situ data collection
• photo-interpretation of very high-resolution satellite imagery
12
Supervised classification - Create training set (1)
14
Supervised classification - Create training set – predefine possible values (1)
15
Supervised classification - Create training set – predefine possible values (2)
16
Supervised classification – Activate base map – QuickMapServices (1)
17
Supervised classification – Activate base map – QuickMapServices (2)
18
Supervised classification - Create training set – Start editing training vector
19
Supervised classification - Create training set – Add Non built-up class features
20
Supervised classification - Create training set – Add Built-up class features
21
Supervised classification - Create training set – conclude editing
22
Supervised classification
23
Supervised classification – Activate dzetsaka classification tool
24
Supervised classification - Classification with dzetsaka (1)
25
Supervised classification - Classification with dzetsaka (2)
26
Supervised classification - Classification with dzetsaka (3)
27
Further information about classification algorithms included in dzetsaka
28
Validation
29
Assessing the success of the classification - validation
Using portion of training data for validation is just one approach for
doing validation (internal validation – cross-validation)
Often validation is conducted independently of training data set.
Validation must ensure:
• Appropriate sample size - Enough samples with minimum cost
• Statistical – Calculate the number of samples based on binomial or In QGIS there is the AcATaMa
normal approximation to the binomial distribution (Cochrane, 1977)* plugin designed for the
• Empirical – number of samples is driven by the available budget (not accuracy estimation of land
suggested) cover maps.
• Sample Allocation: It supports :
• Random – samples are distributed randomly in the area of interest • different steps in creation of
• Stratified random sampling – split area of interest into strata and then training samples (e.g., sample
select samples in each strata size definition and sample
• Equal sample size per strata allocation)
• Number of samples per strata adjusted according to the strata size • a user-friendly interface for
• Other photo interpretation of
• Confident source of reference information: samples and
• In situ data collection • the calculation of multiple
• Photo-interpretation of higher resolution imagery accuracy indexes
*https://hwbdocuments.env.nm.gov/Los%20Alamos%20National%20Labs/General/14447.pdf
30
Error matrix and accuracy indexes
Reference
1 Non built-up 19309 15 19324 99.9%
19309 15
2 Built-up 26 3821 3847 99.3%
26 3821
Sum prediction 19335 3836 23171
UA 99.9% 99.6% 99.8%
• Producer’s accuracy (PA) of a class is probability
that the class present on the ground is also 𝟏𝟗𝟑𝟎𝟗
𝑷𝑨𝑵𝒐𝒏 𝒃𝒖𝒊𝒍𝒕−𝒖𝒑 = ∗ 𝟏𝟎𝟎 = 𝟗𝟗. 𝟗%
captured by the classification in the thematic raster. 𝟏𝟗𝟑𝟐𝟒
𝟑𝟖𝟐𝟏+𝟏𝟗𝟑𝟎𝟗
𝑶𝑨 = ∗ 𝟏𝟎𝟎 = 𝟗𝟗. 𝟖%
𝟐𝟑𝟏𝟕𝟏
31
Inter-comparison
32
Assessing the success of the classification – inter-comparison (1)
The classification success can be estimated by comparison with other maps with the
same theme by computing the error matrix and the accuracy indexes like Overall
accuracy, PA and UA. Instead of PA and UA, the Commission error (1-UA) and Omission
error (1-PA) can also be used. Moreover, another index, the Kappa index, is often
computed.
33
Assessing the success of the classification – inter-comparison (2)
34
Graphical modeler for multiple step processes
35
Graphical modeler - workflow
36
Graphical modeler – Define input data (1)
37
Graphical modeler – Define input data (2)
Input parameters are the first to be
defined in the model. When defining
input parameters, we should keep in
mind the expected data type that will be
used in the model.
In our case the first input layer
is the classification output raster we
produced before.
1. Go to Inputs tab
2. Double click on Raster Layer
3. Insert the name you want to assign
to this Raster Layer in the
Description field (e.g., Classified
Raster)
4. Click on OK
1. Go to Inputs tab
2. Double click on Multiple Input
3. Insert the inputs parameter
name in the Parameter name
field (e.g., Raster tiles)
4. Select Raster Data type
5. Click on OK
39
Graphical modeler – Change values of classification output
1. Go to Algorithms tab
2. Search for Raster calculator in the
search bar
3. Double click on Raster Calculator in
Raster analysis
4. Define Expression (e.g. “Classified
Raster@1”-1)
5. Open Reference layer Multiple selection
window
6. Select Classified Raster so that output
CRS, extent, and cell size are adjusted
according to this layer
7. Click on OK
40
Graphical modeler – Merge multiple raster into one
1. Go to Algorithms tab
2. Search for Merge in the search bar
3. Double click on Merge in GDAL →Raster
miscellaneous
4. For selecting Input layers open Multiple
selection window
5. Select input layers (e.g., Raster tiles)
6. Click on OK to confirm selection
7. Select Output data type to be integer
(e.g., Int32)
8. Click on OK
41
Graphical modeler – Reproject
1. Go to Algorithms tab
2. Search for Warp (reproject) in the
search bar
3. Select Warp (reproject) in GDAL→Raster
projections
4. Selecting Input layer from drop-down
menu (e.g., outcome of merge operation
denoted as ‘Merged’ from algorithm
‘Merge’)*
5. Select Source CRS (e.g., EPSG: 3857)
6. Select Target CRS (e.g., EPSG: 32637)
7. Click on OK
42
Graphical modeler – Reproject - QGIS 3.16
1. Go to Algorithms tab
2. Search for Warp (reproject) in the
search bar
3. Select Warp (reproject) in GDAL→Raster
projections
4. Select Algorihtm Output as a source of
input data
5. Selecting Input layer from drop-down
menu (e.g., outcome of merge operation
denoted as ‘Merged’ from algorithm
‘Merge’)*
6. Select Source CRS (e.g., EPSG: 3857)
7. Select Target CRS (e.g., EPSG: 32637)
8. Click on OK
43
Graphical modeler – Clip raster by extent
Now we clip GHS-BUILT S1 to the extent of the
classification output
1. Go to Algorithms tab
2. Search for Clip raster by extent in the
search bar
3. Select Clip raster by extent in
GDAL→Raster extraction
4. Selecting Input layer from drop-down
menu (e.g., the outcome of reprojection
denoted as ‘Reprojected’ from algorithm
‘Warp(reproject)’)
5. Selectin in Clipping extent the layer based
on which the clipping extent will be
calculated (e.g., Extent of Classified Raster)
6. Click on OK
44
Graphical modeler – Fill no data values
1. Go to Algorithms tab
2. Search for r.null in the search bar
3. Select Clip raster by extent in
GRASS→Raster (r.*)
4. Select Name of raster map for which to
edit null values from drop-down menu
(e.g., outcome of clipping denoted as
‘Clipped (extent)’ from algorithm ‘Clip
raster by extent ’)
5. Insert The value to replace the null
value (e.g., 0.0)
6. Click on OK
45
Graphical modeler – Compute accuracy indexes
Now data are ready to be compared by means of
error matrix and accuracy indexes. For that, we
use the r.kappa algorithm.
1. Go to Algorithms tab
2. Search for r.kappa in the search bar
3. Select r.kappa in GRASS→Raster(r.*)
4. Select Raster layer containing classification
result from drop-down menu (e.g.,
preprocessed classification output denoted
as ‘Output’ from algorithm ‘Raster
calculator’)
5. Select Raster layer containing reference
classes from drop-down menu (e.g.,
preprocessed comparison dataset output
denoted as ‘NullRaster’ from algorithm
‘r.null’)
6. As this is the final goal of a model, specify
Error matrix and Kappa so that the outcome
of this operation become output parameter
(e.g., Error_matrix)
7. Click on OK
46
Graphical modeler – Save model and run it
47
Graphical modeler – Load and run existing model
48
Graphical modeler – Run the model
49
Graphical modeler for multiple step processes
Reference
Sum
1 Non built-up 2 Built-up prediction UA
classification
Prediction/
Result of r.kappa:
• % Commission (error)=1-UA
• % Omission (error)=1-PA
• % Observed correct =Overall accuracy
• Kappa
50
Maria Antonia Brovelli and Gorica Bratic
maria.brovelli@polimi.it; gorica.bratic@polimi.it
52