Object-based classification (Tutorial)

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Training phase)
Line 79: Line 79:
 
* In the search engine of mapla, type {{typed|text=Train}} and double click '''TrainVectorClassifier'''.
 
* In the search engine of mapla, type {{typed|text=Train}} and double click '''TrainVectorClassifier'''.
 
* ''Name of the input shapefile'' is {{button|text=train_input_OBIA.shp}}.
 
* ''Name of the input shapefile'' is {{button|text=train_input_OBIA.shp}}.
* ''Output model filename'' is {{button|text=SVM_OBIA.model}}
+
* ''Output model filename'' is {{button|text=lucc_svm_obia.model}}
* In the list ''Field names for training featrues'' mark the columns {{button|text=meanB0, meanB1, meanB2, .. meanB9}} shift left+ click.
+
* In the list ''Field names for training featrues'' mark 11 columns: {{button|text=B1mean, B2mean, B2stdev, B3mean, B4mean, B5mean, B6mean, B7mean, B7stdev, B9mean, B9stdev, B10mean}} with Ctrl + left-click.
* The name of''Field containing the class id for supervision" is {{button|text=C_ID}}.{{button|text=Execute}}.
+
* The name of ''Field containing the class id for supervision" is {{button|text=C_ID}}.{{button|text=Execute}}.
* Classifier to use for training: '''LibSVM Linear'''
+
* Classifier to use for training: '''LibSVM classifier'''
* Parameters optimization is '''ON'''.
+
* SVM Kernel Type: '''Linear'''
 +
* SVM Model Type: '''C support vector classifiaction'''
 +
* Click Parameters optimization{{button|text=ON}}.
 
[[File:Qgis_otb_trainVectorClassifier.png|400px]]
 
[[File:Qgis_otb_trainVectorClassifier.png|400px]]
 
{{info|message=Info|text=For more detailed information on the SVM algorithm visit the [http://www.csie.ntu.edu.tw/~cjlin/libsvm/ LibSVM website]}}
 
{{info|message=Info|text=For more detailed information on the SVM algorithm visit the [http://www.csie.ntu.edu.tw/~cjlin/libsvm/ LibSVM website]}}

Revision as of 13:41, 7 July 2019

Contents

Preparation of training data

  • Create a dense regular point grid Vector --> Research tools --> Regular points... with the extent of the multispectral image and a point spacing of 200 meters.
  • Install the Point sampling plugin.
  • Extract the landcover class from an existing thematic classifcation map using the Point Sampling Tool.

Qgis point sampling.png.

  • Select 50 points in each class stratified sampling with equal allocation: Vector --> Resarch tools --> Random section within subsets....

Qgis random selection.png.

  • Rename the class field name to C_ID and change the datatype to int using Processing --> Vector table --> Refactor field.
  • Join the Land use/cover (LUC) class attribute of the selected regular points with the segments (output of Feature extraction). Vector --> Data Management Tools --> Join Attributes by Location ....

Qgis joinLayer.png

  • Interpret the C_ID class by visual interpretation of Google satellite as reference.

Object-based image analysis (OBIA) with QGIS and OTB processing plugin

Segmentation

  • In the search engine of Processing Toolbox, type segmentation and double click Segmentation.
  • Set Segmentation algorithm to meanshift
  • Select the input image: Subset_S2A_MSIL2A_20170619T_MUL.tif (data type uint 16bits).
  • The Range radius value can be set to 600. The optimal value depends on datatype dynamic range of the input image and requires experimental trials for the specific classifcation objectives.
  • Set Minimum Region size (in pixels) to 25.
  • Processing mode Vector
  • Set the Mask image to blank (top of dro-down list).
  • The Minimum Segment size (in pixels) can be set to 25 depending on minimum mapping size.
  • Check 8-neighborhood connectivity on.
  • Change Output pixel type to uint32.
  • Name the Output vector file e.g. lucc_meanshift_seg.shp.
  • Define the Output labeled image as lucc_meanshift_seg.tif.
  • Click Run.

Qgis otb segmentation.png

  • Evaluate the segmentation results: Load the output vector file lucc_meanshift_seg.shp into QGIS on top of the image Subset_S2A_MSIL2A_20170619T_Mul.tif

Mark the vector layer in the Qgis Layers window. Layer --> Properties --> Symbology --> Simple Fill, Fill Style: No Brush and Stroke color:white.

Feature extraction

  • In the search engine of Processing Toolbox, type zonal and double click Zonal Statistics.
  • Select the Raster layer: Subset_S2A_MSIL2A_20170619T_MUL.tif .
  • Set Raster band Band 01.
  • The vector layer containing zones is the result from Segmentation: lucc_meanshift_seg.tif.
  • Change output column prefix to the original Sentinel-2 band name: B1
  • In the list Statistics to calculate just check two measures: Mean and Std. dev..
  • Click Run.

Qgis zonal stats.png

  • Repeat the procedure for bands 02, 03, 04, 05, 06, 07, 08, 09, 10.
  • Open the attribute table of vector layer lucc_meanshift_seg.tif containing now statistics for each zone or segment.

Training phase

Qgis otb trainvector.png

Classification phase

Qgis otb vectorclassifier.png

Object-based image analysis (OBIA) with OTB standalone

Segmentation

  • Type into the search box of the Windows taskbar: mapla.bat. Click on mapla.bat to open Monteverdi Application Launcher.
  • In the search engine of mapla, type Meanshift and double click LargeScaleMeanshift.
  • Select the input image: Subset_S2A_MSIL2A_20170619T_MUL.tif (datatype uint 16bits).
  • The Range radius value can be set to 600. The optimal value depends on datatype dynamic range of the input image and requires experimental trials for the specific classifcation objectives.
  • The value for Minimum Segment size (in pixels) can be set to 10. It depends on the size of the minimum mapping unit and the smallest object that can be destinguished.
  • Leave all other configurations as they are and click Run. Have a look on the resulting filtered and spatial images.
  • The Output GIS vector file is specified as a shapefile with the extension *.shp.
  • Click Execute.

Otb segmentation.png

  • Evaluate the segmentation results:

Load the output vector file into QGIS on top of the image Subset_S2A_MSIL2A_20170619T_Mul.tif Mark the vector layer in the Qgis Layers window. Layer --> Properties --> Symbology --> Simple Fill to No Brush and Stroke color to white.

info.png Info
For more detailed information on the SVM algorithm visit the LibSVM website

Feature extraction

  • In the search engine of Processing Toolbox, type zonal and double click Zonal Statistics.
  • Select the Raster layer: Subset_S2A_MSIL2A_20170619T_MUL.tif .
  • Set Raster band Band 01.
  • The vector layer containing zones is the result from Segmentation: lucc_meanshift_seg.tif.
  • Change output column prefix to the original Sentinel-2 band name: B1
  • In the list Statistics to calculate just check two measures: Mean and Std. dev..
  • Click Run.

Qgis zonal stats.png

  • Repeat the procedure for bands 02, 03, 04, 05, 06, 07, 08, 09 and 10.
  • Open the attribute table of vector layer lucc_meanshift_seg.tif containing now statistics for each zone or segment.

Training phase

  • In the search engine of mapla, type Train and double click TrainVectorClassifier.
  • Name of the input shapefile is train_input_OBIA.shp.
  • Output model filename is lucc_svm_obia.model
  • In the list Field names for training featrues mark 11 columns: B1mean, B2mean, B2stdev, B3mean, B4mean, B5mean, B6mean, B7mean, B7stdev, B9mean, B9stdev, B10mean with Ctrl + left-click.
  • The name of Field containing the class id for supervision" is C_ID.Execute.
  • Classifier to use for training: LibSVM classifier
  • SVM Kernel Type: Linear
  • SVM Model Type: C support vector classifiaction
  • Click Parameters optimizationON.

Qgis otb trainVectorClassifier.png

info.png Info
For more detailed information on the SVM algorithm visit the LibSVM website

Classification phase

  • In the search engine of mapla, type Vector and double click VectorClassifier.
  • Name of the input vector data is lab10_segments.shp.
  • Name of the input model file is SVM_OBIA.model.
  • Mark in the list Field names to be calculated the same features as for training!
  • Specify the Output vector file. Execute

Qgis otb vectorClassifier.png

Validation phase

Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export