Unsupervised classification (Tutorial)

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
Line 48: Line 48:
 
## Open the k-means classification algorithm provided by the Orfeo toolbox. It can be found in the processing toolbar under {{mitem|text=Toolbox --> Orfeo Toolbox --> Learning --> Unsupervised KMeans image classification}} (see figure '''A''').
 
## Open the k-means classification algorithm provided by the Orfeo toolbox. It can be found in the processing toolbar under {{mitem|text=Toolbox --> Orfeo Toolbox --> Learning --> Unsupervised KMeans image classification}} (see figure '''A''').
 
##* Set the ''188_pca_indices'' layer as {{button|text=Input image}}.
 
##* Set the ''188_pca_indices'' layer as {{button|text=Input image}}.
 +
##* Training set size: 100000
 
##* Set the {{button|text=Number of classes}} to 20 and the {{button|text=Number of iterations}} to 1000.
 
##* Set the {{button|text=Number of classes}} to 20 and the {{button|text=Number of iterations}} to 1000.
 
##* The {{button|text=Convergence threshold}} should be set at 0.0001.
 
##* The {{button|text=Convergence threshold}} should be set at 0.0001.

Revision as of 13:21, 12 December 2016

In this article, you will learn how to classify a landscape raster via k-means clustering
Table A
Code Name Cluster number RGB color
1 Urban area 10,9,15 230-000-077
2 Cropland 16,0,13,3,7,17,18 255-255-168
3 Pastures/grassland 12,8 230-230-077
4 Broadleaved forest 6,2,5,4 128-255-000
5 Coniferous forest 11,19 000-166-000
6 Water bodies 14 128-242-230
7 Cloud 1 255-255-255
  1. Classifying an image
    1. Add the raster layer 188_pca_indices.tif into a QGIS project. It should be available in the course data (see previous exercise).
    2. Open the k-means classification algorithm provided by the Orfeo toolbox. It can be found in the processing toolbar under Toolbox --> Orfeo Toolbox --> Learning --> Unsupervised KMeans image classification (see figure A).
      • Set the 188_pca_indices layer as Input image.
      • Training set size: 100000
      • Set the Number of classes to 20 and the Number of iterations to 1000.
      • The Convergence threshold should be set at 0.0001.
      • Leave all other configurations as they are and click Run. The resulting image has 20 classes, labeled from 0 to 19.
  2. Image symbology
    1. Right-click the classified layer in the TOC and select Properties --> Style (see figure B).
    2. Set the Render type to Singleband pseudocolor.
    3. Set Color interpolation to Discrete.
    4. In the Load min/max section, select the Min/max radio button and click Load to update the range for classification.
    5. Set the Mode to Equal interval with 20 classes and confirm with Classify.
    6. Confirm with Apply or click OK if you are content with your settings.
  3. Create a land use/cover classification scheme table as in table A.
    1. As a reference, you may add a google layer to the project:
      Web --> ObenLayers plugin --> Add Google Satellite layer.
    2. Set the coordinate reference system
    3. Open Project --> Project properties.
    4. Set WGS 84 Pseudo Mercator (EPSG 3857) as coordinate system
    5. Check the Enable on the fly transformation box
    6. Right click 188_pca_indices in the TOC and select Set Project CRS from layer.
    7. Order the maps in the TOC so that the classified layer lies above the Google Maps layer.
    8. Now, zoom in to some section of the classified layer where the classes can easily be distinguished.
    9. Activate and de-activate the layer in the TOC and compare to the Google layer in order to get an idea of the classes.
    10. While doing so, create a table displaying which classes in the classified layer may represent the classes in table A. You can write it down on a sheet of paper or save it as a text file on your computer.
  4. Change the grid values
    1. Select Saga --> Grid-Tools --> Change grid values from the Processing toolbox.
      • As Grid, select the output map from the previous step.
      • From the Replace condition pulldown menu, select [2] Low value <= grid value < high value.
      • Now, open the lookup menu table (...) and enter the values you have written down in the previous step.
      • Set path and name of the output file and launch the algorithm with Run.
  5. Assign discrete colors to the land cover layer (figure C).
    1. Right click the layer in the TOC or double click to open the layer Properties.
    2. Select the Style tab and set the following options:
      • For Render type select Singleband pseudocolor
      • For Color interpolation, select Discrete
      • Set Mode to Equal interval and Classes to 7.
      • Set Load min/max values to Min/max.
      • For better interpretation, you can edit the Label column in the classes section according to the class names in table A.
      • Don't forget to click Classify for adding the classes.
    3. Click Load and confirm with Apply or OK.

Figures

Figure A: Dialogue of the Unsupervised K-Means image classification plugin from the Orfeo toolbox in QGIS.
Figure B: Land cover map produced by the k-means clustering algorithm.
Figure C: Land cover map produced by the k-means clustering algorithm in discrete colors.
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export