Land Cover/Use Classification using the Semi-Automatic Classification Plugin for QGIS

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
Line 91: Line 91:
 
# Open {{mitem|text=SCP Dock --> Classification dock --> Classification output}} and click the button [[File:Output_button.PNG]] to specify an output destination. Results will be displayed in QGIS canvas after the processing.
 
# Open {{mitem|text=SCP Dock --> Classification dock --> Classification output}} and click the button [[File:Output_button.PNG]] to specify an output destination. Results will be displayed in QGIS canvas after the processing.
 
# Repeat with other algorithms to compare their performance.
 
# Repeat with other algorithms to compare their performance.
 +
 +
[[Category:QGIS Tutorial]]

Revision as of 15:32, 4 December 2017


Contents

Working steps

Preparing raster data (Converting DN to reflectance)

  1. Load the multiband raster file Subset_S2A_MSIL2A_20170619T.tif available in the course data. This contains all 13 bands of Sentinel-2 scene.
  2. Follow Split stack to extract bands 2, 3, 4, 5, 6, 7, 8, 11 and 12, using the multiband raster file Subset_S2A_MSIL2A_20170619T.tif as input layer.
  3. In the processing toolbar, type Raster calculator into the search field to find the GDAL\OGR --> Raster calculator tool and open it.
  • Click the button Run as batch process..., and use Add row Add rows.PNG button to add enough processing rows.
  • Click the button ... of Input layer A to select the single extracted bands as input layers (i.e. one per row).

Convert DN to reflectance.png

  • Enter and repeat the expression A/10000 under Calculation in gdalnumeric syntax using +-/* or any numpy array functions (i.e. logical_and()) and set Output raster type to Float32

Batch2.png

  • Click the button ... of Calculated to save output file
  • Click Run
  1. Follow Create stack to create a multiband raster file from the converted single bands from step 3 and load into QGIS canvas.

Install and set up SCP plugin

  1. Click Plugins --> Manage and Install Plugins.
  2. Type in the search bar semi-Automatic Classification, click on the plugin name and then on Install plugin.

SCP plugin intall.png

  • Right-click on the Plugin Toolbar and make sure the following are checked SCP Dock, SCP Edit Toolbar, SCP Tools and SCP Working Toolbar.

SCP Tool.png

Defining classification inputs in SCP-plugin

We need to define input image, training input and spectral signature files for SCP.

  1. Open the SCP Dock.
  2. Click SCP Dock --> SCP input --> Input image, use the button Refresh list Refresh list.PNG and the drop-down menu-bar to select the multiband Merge file (i.e. from DN to Reflectance conversion) as input image.
  3. Click the button Band set Band set.PNG to further define the input image.
  4. Next, click Quick wavelength settings and select Sentinel-2 from the list in order to automatically set the Center wavelength for each band and the Wavelength unit (NB. required for spectral signature assessment).
  5. In the RGB list Working toolbar.PNG of the Working Toolbar, select 3-2-1 to display natural color composite. Also, type in 4-3-2 to display false color composite. While changing the color composite; also use the buttons cumulative_stretch Cum stretch.PNG and std_dev_stretch Stdv stretch.PNG for better displaying the Input image (i.e. image stretching).
  6. We need to define training input file in order to collect ROIs and spectral signatures.
  7. Click SCP Dock --> SCP input --> Training input, use the button Create a new training input Training input.PNG to create a training signature file with the extension .scp, click save.

Scp dock.png Scp input.png Quick wavelength settings.png Natural color.PNG False color.PNG

Collection of ROIs and Spectral signatures

  1. Click on the button Add Vector Layer QGIS 2.0 addvect.png to Load the vector file Training_points_refactored.shp available in the course data and overlay it on the multiband Merge' layer.
  2. To display attribute labels for Training_points_refactored.shp, right-click to open Properties --> Labels. Select Show labels for this layer and Label with C_ID.
  3. ROIs can be created by drawing polygons using the button Create a ROI polygon Create polygon.PNG or by an automatic region growing algorithm using the button Activate ROI pointer ROI pointer.PNG. The region growing algorithm can create more homogeneous ROIs (i.e. standard deviation of spectral signature values is low) than manually drawn ones; the manual creation of ROIs can be useful in order to account for the spectral variability of classes. We will use the automatic region growing algorithm.
  4. From SCP Dock --> Classification dock --> ROI creation, check the function Display NDVI.
  5. Next, click the button Activate ROI pointer ROI pointer.PNG, and notice that the cursor displays NDVI value which changes over the image pixels.
  6. Zoom-in to the points and click on a land cover/use pixel associated with the point attribute to create a ROI.
  7. On the Working Toolbar, increase the Dist parameter Dist.PNG (e.g. from 0.010000 to 0.100000), and click the button Redo the roi at the same point Redo.PNG to capture more of similar pixels.
  8. Still under SCP Dock --> Classification dock --> ROI creation, set MC_ID, C_ID, MC_info and C_info according to the point attribute (see attribute table), and click on the button Save temporary roi to training input Calculate sig.PNG to record spectral signature. Also set color for ROIs by double-clicking on Color from the ROI Signature list.
  9. Repeat step 6, 7 and 8, to record several land cover/use ROIs and spectral signatures for all points.

Roi 1.png Roi 2.png

Assess Spectral Signatures

Premise: Different materials may have similar spectral characteristics. As such pixels could be misclassified due to inability of classification algorithms to correctly discriminate those spectral signatures. Thus it is important to review spectral signatures of training samples and repeatedly modify them until all class training sets achieve adequate spectral separability. This can be done by 1) displaying and assessing spectral plots and/or 2) calculating the spectral distances of signatures.

  1. Highlight spectral signatures in the ROI Signature list and click the button Add highlighted signatures to spectral signature plot Spec sig plot.PNG to display signature plot.
  2. Disable/enable plot value range by checking/unchecking Plot value range.
  3. Observe differences in Pasture and Annual crops accross all wavelength ranges.
  4. Use the Automatic thresholds Auto treshold.PNG field to refine signature separability. It is also possible to refine the range within the plot. In the Plot Signature list, highlight a signature, click on the button Change value range interactively in the plot Edit range interactive.PNG, click inside the plot to reduce or increase range. (NB. classes are well separated if there is no overlap in at least one band)
  5. For the highlighted signatures click the button Calculate spectral distances Calc sig diff.PNG
  6. Click Signature details to unfold signature statistics for each wavelength range.
  7. Click Pectral distances to reveal spectral signature (dis)similarity metrics.
  8. To examine scatter plots for the highlighted signatures click the button Add highlighted items to scatter plot Sct plot.PNG to display scatter plot.

Spec plot.png


Plot no value range.png


Past AnnualCrop.png


Sig details.png


Spec dist.png


Scatter plot.png

Classification

Land cover/use classification

Create some classification previews to get an overview of how the process will perform. This also helps to improve on the spectral signatures of training input for better classification results.

  1. Click SCP Dock --> Classification dock --> Macroclasses to set the colours for each class.
  2. Then under SCP Dock --> Classification dock --> Classification algorithm, check Use MCID to use Macroclass IDs for classification. For the algorithm, select Maximum Likelihood and under Land Cover Signature Classification check the box next to LCS.
  3. On the Working Toolbar click the button Preview pointer.PNG to activate the classificatin preview pointer.
  4. Then click a point on the image to display a classification preview in the map. Use the button Zoom to preview.PNG to zoom to the classification preview.

Classification can be performed after ROI creation and definition of spectral ranges.

  1. When satisfied with the preview and training input, check the box next to Algorithm under Land Cover Signature Classification.
  2. Open SCP Dock --> Classification dock --> Classification output and click the button Output button.PNG to specify an output destination. Results will be displayed in QGIS canvas after the processing.
  3. Repeat with other algorithms to compare their performance.
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export