Object-based classification (Tutorial)

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Feature extraction)
 
(176 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{construction}}
+
==Preparation of training data==
 +
* Create a dense regular point grid {{mitem|text=Vector  --> Research tools --> Regular points...}} with the extent of the multispectral image and a point spacing of {{typed|text=200}} meters.
 +
* Install the Point sampling plugin.
 +
* Extract the landcover class from an existing thematic classifcation map using the Point Sampling Tool.
 +
[[File:qgis_point_sampling.png|300px]].
 +
* Select 50 points in each class stratified sampling with equal allocation: {{mitem|text=Vector  --> Resarch tools --> Random section within subsets...}}.
 +
[[File:qgis_random_selection.png|300px]].
 +
* Rename the class field name to '''C_ID''' and change the datatype to '''int''' using {{mitem|text=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). {{mitem|text=Vector  --> Data Management Tools --> Join Attributes by Location ...}}.
 +
[[File:qgis_joinLayer.png|400px]]
 +
* Interpret the C_ID class by visual interpretation of Google satellite as reference.
  
:''This exercise is part of the [[QGIS Tutorial 2013/14]]''
+
=Object-based image analysis (OBIA) with QGIS and OTB processing plugin=
 +
==Segmentation==
 +
* In the search engine of Processing Toolbox, type {{typed|text=segmentation}} and double click '''Segmentation'''.
 +
* Set {{button|text=Segmentation algorithm}} to '''meanshift'''
 +
* Select the input image: '''Subset_S2A_MSIL2A_20170619T_MUL.tif ''' (data type uint 16bit).
 +
* The {{button|text=Range radius}} value can be set to {{typed|text=600}}. The optimal value depends on datatype dynamic range of the input image and requires experimental trials for the specific classifcation objectives.
 +
* Set {{button|text=Minimum Region size}} (in pixels) to {{typed|text=16}}.
 +
* {{button|text=Processing mode}} '''Vector'''
 +
* Set the {{button|text=Mask image}} to blank (top of dro-down list).
 +
* The {{button|text=Minimum Segment size}} (in pixels) can be set to {{typed|text=16}} depending on  minimum mapping size.
 +
* Check {{button|text=8-neighborhood connectivity}} on.
 +
* Name the {{button|text=Output vector file}} e.g. '''lucc_meanshift_seg.shp'''. (Filetype shapefile is here mandatory)
 +
* Click {{button|text=Run}}.
 +
If no-data are defined in the input image you will get the warning: "this application does not handle no-data". Ignore and load the shapefile with segments manually.
  
== Determining segmentation parameters ==
+
[[File:qgis_otb_segmentation.png|400px]]
# Start Monteverdi: {{mitem|text=Start-All programs-OSGeo4W-Monteverdi}}
+
# Open dataset in Monteverdi: {{mitem|text=File – Open dataset }} e.g. ''188_pca_indices_pan.tif''
+
# Subset data to a small area: {{mitem|text=File – Extract ROI from dataset }}, in the field {{button|text=Image to read – Reader0}}select file e.g. 188_pca_indices_pan.tif and press {{button|text=OK}}
+
# Drag the mouse in {{mitem|text=Select the ROI}} window to select a region equivalent to 500 x 500 pixels and Press {{button|text=OK}} to make an output image; ExtractROI1
+
# Perform mean shift segmentation: {{mitem|text=Filtering-Mean shift clustering}}, in the field {{button|text=image to apply shift on}} select output image from step 4. The Mean shift module window opens. Set the following parameters. Spatial radius = 5, Spectral values = 0,5, Min region size = 57. {{button|text=Check}} Display Boundaries, Display cluster and {{button|text=Run}}. An output named-Labeled image-is created (Figure '''A'''). Finally click {{button|text=Close}} to create all the output in Monteverdi window.
+
  
{{red|text=Figure A: Mean Shift Module}}
+
* 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. {{mitem|text=Layer --> Properties --> Symbology  --> Simple Fill}}, {{mitem|text=Fill Style}}: ''No Brush'' and {{mitem|text=Stroke color}}:''white''.
  
== Object labeling and segmentation via SVM ==
+
==Feature extraction==
# Object labeling: Go to {{mitem|text=Learning-Object Labelling}}, in the field {{button|text=The image to classify}} select file {{mitem|text=ExtractROI-OutputImage}}  obtained in A above and in the field {{button|text=The segmentation of the image}} select file {{mitem|text=MeanShift1-Labeled Image}} and press {{button|text=OK}}. A window {{mitem|text=Object Labelling}} opens.  
+
In the search engine of Processing Toolbox, type {{typed|text=zonalstats}} and open '''ZonalStatistics''' under Image Manipulation of OTB.
# Click Add to start object labeling. A new class appears in the {{button|text=Objects}} tab in the upper right corner of the window. Specify color red for New Class 0 = Urban.  Double right click the image to select 10 urban objects as visually intepreted. Repeat the same procedure for New Class 1 = Cropland in yellow color and New Class 2 = Forest in green color.
+
* Select the Input image: '''Subset_S2A_MSIL2A_20170619T_MUL.tif '''.
# Selecting shape and pixel parameters for object clustering: In {{button|text=Features}} tab {{button|text=check }} STATS::Band1::Mean, STATS::Band2::Mean, STATS::Band3::Mean
+
* Background value to ignore: {{typed|text=65535}}
# Selecting Support Vector Machines (SVM) parameters: Leave other parameters to default and {{button|text=check}} Parameters optimization. Click {{button|text=classify}} to obtain the output,  observed in Figure '''B'''. Using the {{button|text=Opacity}} slide, you can corroborate the output with the original image. Take note of the accuracy measure in the lower right side of the window.  
+
* The input vector data is the result from Segmentation: '''lucc_meanshift_seg.shp'''.
# Try to {{button|text=Check}} other Features in the {{button|text=Features}} tab and compare output clusters with the output of parameters specified at step 3.  
+
* File name for the output vector data: '''lucc_meanshift_seg_stats.shp'''.
NB: For more detailed information on the SVM algorithm visit the library website on: http://www.csie.ntu.edu.tw/~cjlin/libsvm/
+
* Click {{button|text=Run}}.
 +
[[File:otb_zonalstats.png|400px]]
  
{{red|text=Figure B: SVM output}}
+
Alternative module:
 +
* In the search engine of Processing Toolbox, type {{typed|text=zonal}} and double click '''Zonal Statistics'''.
 +
* Select the Raster layer: '''Subset_S2A_MSIL2A_20170619T_MUL.tif '''.
 +
* Set Raster band  {{button|text=Band 01}}.
 +
* The vector layer containing zones is the result from Segmentation: '''lucc_meanshift_seg.shp'''.
 +
* Change output column prefix to the original Sentinel-2 band name: {{typed|text=B1}}
 +
* In the list Statistics to calculate just check two measures: '''Mean''' and '''Std. dev.'''.
 +
* Click {{button|text=Run}}.
 +
[[File:qgis_zonal_stats.png|400px]]
 +
* Repeat the procedure for bands 02, 03, 04, 05, 06, 07, 08, 09, 10.
 +
* Open the attribute table of vector layer '''lucc_meanshift_seg.shp''' containing now statistics for each zone or segment.
  
== Object based segmentation by mean shift clustering ==
+
==Training phase==
# Load the raster map; 188_pca_indices_pan.tif provided in course data. Open {{button|text=Mean Shift Segmentation (Large scale, vector output)}} by searching the Orfeo toolbox.  
+
* In the search engine of Processing Toolbox, type {{typed|text=Train}} and double click '''TrainVectorClassifier'''.
# Select input image 188_pca_indices_pan.tif.  Change {{button|text=Range radius}} = 0,5 and {{button|text=Min Region size}} = 50. Specify outfile as Segments_all.shp and {{button|text=RUN}}.  
+
* ''Name of the input shapefile'' is {{button|text=train_input_OBIA.shp}}.
# Load Segments_all.shp. To view both the vector segments and the underlying image file, visualize the segments as hollow polygons. Right click on Segments_all.shp {{mitem|text=Properties-Styles-Fill-Simple fill-Fill style-No brush}} and change the border outline to colour white for better visibility {{mitem|text=Properties-Styles- Border-White}}. See figure C.
+
* ''Output model filename'' is {{button|text=lucc_svm_obia.model}}
# Spilt the multiband image 188_pca_indices_ pan_mean.tif to single band rasters. This step is necessary to allow extraction of individual segment spectral values using the zonal statistics tool as shown in step 5: Open {{mitem|text=Split image}} tool from the Orfeo toolbox. {{mitem|text=Image manipulation-Split image}} and specify output image.
+
* In the field ''Field names for training features'' copy and paste
# Extract pixel spectral data for each object using the Zonal statistics Plugin: Install Zonal Statistics Plug in from {{mitem|text=Plugin-Manage and Install plugin-Get more-Zonal statistics plugin}}. Open the Zonal Statistics tool from {{mitem|text=Raster-Zonal statistics- Zonal statistics}} and specify the Raster layer, Polygon layer containing the zones and Output column for Bands 1, 2 and 3 respectively.
+
for OTB 7.0.0 Zonalstatistics module:
# Rasterize the segments to prepare for classification: Open the Rasterization tool from the Orfeo tool box {{mitem|text=Vector Data Manipulation-Rasterization}}. Select {{button|text=Input vector dataset}} as Segments_all.shp. Select {{button|text=Input reference image}} as 188_pca_indices_ pan_mean.tif. Input coordinates for the {{button|text=Output Upper-left x}} and {{button|text=Output Upper-left y}}. NB: The coordinates can be found by right clicking on the image file to {{mitem|text=Properties-Metadata}}. Change {{button|text=Spacing (GSD)x}} and {{button|text=Spacing (GSD)y}} spacing to 15 and {{button|text=Rasterization mode}} to attribute. Specify the output file and {{button|text=RUN}}.  
+
<pre> "mean_0 mean_1 stdev_1 mean_2 mean_3 mean_4 mean_5 mean_6 stdev_6 mean_8 stdev_8 mean_9" </pre>
# Collect training objects for Object based Supervised Maximum Likelihood Classification: Select 210 random objects from Segment_all.shp using the random selection tool {{mitem|text=Vector-Research Tools-Random selection}}. Specify {{button|text=Number of Features}} = 210. Press {{button|text=OK}}. Right click on the layer Segment_all.shp and save selected objects as 210_selected.shp and load the new .shp file back in QGIS. 
+
or if you used the qgis zonal statistics module:  
# Specify class for each object in 210_selected.shp file according to table 1. This is the training dataset for maximum likelihood classification. Load the GoogleEarth Image from the OpenLayers plugin {{mitem|text=Plugins-OpenLayers plugin-Add Google Satellite layer}}. Install QuickMultiAttributeEdit plugin in from {{mitem|text=Plugin-Manage and Install plugin-Get more- QuickMultiAttributeEdit }}. The QuickMultiAttruibuteEdit tool simply helps in editing attributes of a vector file without opening the attribute table. Open the QuickMultiAttributeEdit from {{mitem|text=Plugins- QuickMultiAttributeEdit}}.  Right click on 210_selected.shp and open attribute table. Toogle editing mode. Select one row i.e. one segment by clicking on {{mitem|text=zoom map to the selected row}}, identify the land use type by corroborating with google imagery. Press {{button|text=F12}} key to open the QuickMultiAttributeEdit and specify IDClass = corresponding Class Code in Table 1. Repeat this procedure for each segment.
+
<pre> "B1mean B2mean B2stdev B3mean B4mean B5mean B6mean B7mean B7stdev B9mean B9stdev B10mean" </pre>
# Perform maximum likelihood classification of the object segments using the Semiautomatic classification plugin: To open the plugin go to {{mitem|text=Raster-Semi-Automatic Classification Plugin - Semi-Automatic Classification Plugin }}. Click {{button|text=Show docks}}. In the Semi-Automatic:ROI creation window select {{button|text=input}} as 188_pca_indices_ pan_mean.tif., {{button|text=Select a training shapefile}} as train_segments_6class.shp. Leave the ROI parameters to default. In the Semi-Automatic: Classification window {{button|text=select classification algorithm}} to Maximum Likelihood, {{button|text=select qml}} as classification.qml, {{button|text=Check}} Create vector, Apply mask, Classification report and Calculate accuracy. Specify a cloud mask as cloud_mask.shp.  {{button|text=Perform Classification}} and select an output file, semi_automatic classification.shp. An additional output file semi_automatic classification.tif will be created.  See Figure '''D'''. Import the classification style from classification.qml.  To do an accuracy assessment of your map output go  to the {{button|text=Post processing}} tab, {{button|text=Accuracy}},  in the Semi-Automatic Classification Plugin window.  Load semi_automatic classification.tif in {{button|text=Select the classification to assess}} and train_segments_6class.shp in {{button|text=Select the reference shapefile}} and click {{button|text=Calculate error matrix}}.  See Figure '''E'''.
+
* The name of ''Field containing the class id for supervision" is {{button|text=C_ID}}.
 +
* Classifier to use for training: {{button|text=libsvm}}
 +
* SVM Kernel Type: {{button|text=linear}}
 +
* SVM Model Type: {{button|text=csvc}}
 +
* Click Parameters optimization{{button|text=ON}}.
 +
* Click {{button|text=Run}}.
 +
[[File:qgis_otb_trainvector.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]}}
  
{{red|text=Figure C: QGIS Mean shift Clustering Segmentation.}}  
+
==Classification phase==
 +
* In the search engine of Processing Toolbox, type {{typed|text=Vector}} and double click '''VectorClassifier'''.
 +
* Name of the input vector data is {{typed|text=lucc_segments.shp}}.
 +
* Name of the input model file is {{typed|text=lucc_svm_obia.model}}.
 +
* Output field containing the class is {{typed|text=C_ID}}
 +
* Copy and paste into the filed ''Field names to be calculated'' the '''same features''' as in the TrainVectorClassifier module:
 +
for OTB 7.0.0 Zonalstatistics module:
 +
<pre> "mean_0 mean_1 stdev_1 mean_2 mean_3 mean_4 mean_5 mean_6 stdev_6 mean_8 stdev_8 mean_9" </pre>
 +
or if you used the qgis zonal statistics module:
 +
<pre> "B1mean B2mean B2stdev B3mean B4mean B5mean B6mean B7mean B7stdev B9mean B9stdev B10mean" </pre>
 +
* Specify the Output vector file. {{button|text=Run}}
 +
[[File:qgis_otb_vectorclassifier.png|400px]]
  
{{red|text=Figure D: Supervised Maximum Likelihood Classification}}
+
=Object-based image analysis (OBIA) with OTB standalone=
 +
==Segmentation==
 +
* Type into the search box of the Windows taskbar: {{typed|text=mapla.bat}}. Click on mapla.bat to open  Monteverdi Application Launcher.
 +
* In the search engine of mapla, type {{typed|text=Segmentation}} and double click '''Segmentation'''.
 +
* Select the input image: '''Subset_S2A_MSIL2A_20170619T_MUL.tif ''' (datatype uint 16bits).
 +
* The {{button|text=Range radius}} value can be set to {{typed|text=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 {{button|text=Minimum Segment size}} (in pixels) can be set to {{typed|text=25}}. 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 {{button|text=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 {{button|text=Execute}}.
 +
[[File:otb_segmentation.png|500px]]
 +
* 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. {{mitem|text=Layer --> Properties --> Symbology  --> Simple Fill}} to ''No Brush'' and {{mitem|text=Stroke color}} to ''white''.
 +
{{info|message=Info|text=For more detailed information on the SVM algorithm visit the [http://www.csie.ntu.edu.tw/~cjlin/libsvm/ LibSVM website]}}
  
{{red|text=Figure E: Supervised Maximum Likelihood Classification Accuracy}}
+
==Feature extraction==
 +
* In the search engine of Processing Toolbox, type {{typed|text=zonal}} and double click '''Zonal Statistics'''.
 +
* Select the Raster layer: '''Subset_S2A_MSIL2A_20170619T_MUL.tif '''.
 +
* Set Raster band  {{button|text=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: {{typed|text=B1}}
 +
* In the list Statistics to calculate just check two measures: '''Mean''' and '''Std. dev.'''.
 +
* Click {{button|text=Run}}.
 +
[[File:qgis_zonal_stats.png|400px]]
 +
* 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.
  
{{red|text=Figure D: Perform an alternative supervised classification using Support Vector Machines in Monteverdi (Experimental for large datasets)}}
+
==Training phase==
 +
* 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}}.
 +
* ''Output model filename'' is {{button|text=lucc_svm_obia.model}}
 +
* 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}}.
 +
* Classifier to use for training: '''LibSVM classifier'''
 +
* SVM Kernel Type: '''Linear'''
 +
* SVM Model Type: '''C support vector classification'''
 +
* Click Parameters optimization{{button|text=ON}}.
 +
* Click {{button|text=Execute}}.
 +
[[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]}}
  
# Start Monteverdi: {{mitem|text=Start-All programs-OSGeo4W-Monteverdi}}
+
==Classification phase==
#  Open dataset in Monteverdi: {{mitem|text=File – Open dataset }} e.g. 188_pca_indices_pan_mean.tif and train_segments_7class.shp
+
* In the search engine of mapla, type {{typed|text=Vector}} and double click '''VectorClassifier'''.
# Go to {{mitem|text=Learning-SVM classification (EXPERIMENTAL)}}
+
* Name of the input vector data is {{typed|text=lucc_segments.shp}}.
# Load 188_pca_indices_pan_mean.tif to {{button|text=Input image}} and train_segments_7class.shp to {{button|text=Training/validation ROIs}} and press {{button|text=OK}}
+
* Name of the input model file is {{typed|text=lucc_svm_obia.model}}.
# Specify the {{button|text=Class key}} as ID_class and click {{button|text=Train}}. A classification output is seen Monteverdi.
+
* Filed class is {{typed|text=C_ID}}
# Click {{button|text=Validate}} to see classification accuracy.  
+
* Mark in the list ''Field names to be calculated'' the '''same features''' as in the TrainVectorClassifier module (see above) using Ctrl + left-click).
 
+
* Specify the Output vector file. {{button|text=Execute}}
{{red|text=Figure F: SVM classification accuracy}}
+
[[File:qgis_otb_vectorClassifier.png|400px]]

Latest revision as of 10:54, 15 June 2021

Contents

[edit] 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.

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

[edit] 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 16bit).
  • 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 16.
  • Processing mode Vector
  • Set the Mask image to blank (top of dro-down list).
  • The Minimum Segment size (in pixels) can be set to 16 depending on minimum mapping size.
  • Check 8-neighborhood connectivity on.
  • Name the Output vector file e.g. lucc_meanshift_seg.shp. (Filetype shapefile is here mandatory)
  • Click Run.

If no-data are defined in the input image you will get the warning: "this application does not handle no-data". Ignore and load the shapefile with segments manually.

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.

[edit] Feature extraction

In the search engine of Processing Toolbox, type zonalstats and open ZonalStatistics under Image Manipulation of OTB.

  • Select the Input image: Subset_S2A_MSIL2A_20170619T_MUL.tif .
  • Background value to ignore: 65535
  • The input vector data is the result from Segmentation: lucc_meanshift_seg.shp.
  • File name for the output vector data: lucc_meanshift_seg_stats.shp.
  • Click Run.

Otb zonalstats.png

Alternative module:

  • 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.shp.
  • 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.shp containing now statistics for each zone or segment.

[edit] Training phase

  • In the search engine of Processing Toolbox, 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 field Field names for training features copy and paste

for OTB 7.0.0 Zonalstatistics module:

 "mean_0 mean_1 stdev_1 mean_2 mean_3 mean_4 mean_5 mean_6 stdev_6 mean_8 stdev_8 mean_9" 

or if you used the qgis zonal statistics module:

 "B1mean B2mean B2stdev B3mean B4mean B5mean B6mean B7mean B7stdev B9mean B9stdev B10mean" 
  • The name of Field containing the class id for supervision" is C_ID.
  • Classifier to use for training: libsvm
  • SVM Kernel Type: linear
  • SVM Model Type: csvc
  • Click Parameters optimizationON.
  • Click Run.

Qgis otb trainvector.png

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

[edit] Classification phase

  • In the search engine of Processing Toolbox, type Vector and double click VectorClassifier.
  • Name of the input vector data is lucc_segments.shp.
  • Name of the input model file is lucc_svm_obia.model.
  • Output field containing the class is C_ID
  • Copy and paste into the filed Field names to be calculated the same features as in the TrainVectorClassifier module:

for OTB 7.0.0 Zonalstatistics module:

 "mean_0 mean_1 stdev_1 mean_2 mean_3 mean_4 mean_5 mean_6 stdev_6 mean_8 stdev_8 mean_9" 

or if you used the qgis zonal statistics module:

 "B1mean B2mean B2stdev B3mean B4mean B5mean B6mean B7mean B7stdev B9mean B9stdev B10mean" 
  • Specify the Output vector file. Run

Qgis otb vectorclassifier.png

[edit] Object-based image analysis (OBIA) with OTB standalone

[edit] 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 Segmentation and double click Segmentation.
  • 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 25. 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

[edit] 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.

[edit] 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.
  • Classifier to use for training: LibSVM classifier
  • SVM Kernel Type: Linear
  • SVM Model Type: C support vector classification
  • Click Parameters optimizationON.
  • Click Execute.

Qgis otb trainVectorClassifier.png

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

[edit] Classification phase

  • In the search engine of mapla, type Vector and double click VectorClassifier.
  • Name of the input vector data is lucc_segments.shp.
  • Name of the input model file is lucc_svm_obia.model.
  • Filed class is C_ID
  • Mark in the list Field names to be calculated the same features as in the TrainVectorClassifier module (see above) using Ctrl + left-click).
  • Specify the Output vector file. Execute

Qgis otb vectorClassifier.png

Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export