QGIS – Classifying Vector Data Efficiently

classificationdissolveqgisvector

I am trying to classify a shapefile based on rule set, following this tutorial.

This is the result:
enter image description here

What I want to ask is:
1. How to insert the classification result (water, land etc) into the attribute table? I want to make each feature assign to a certain class in the attribute table. enter image description here

  1. How to join the vector contain same class? I tried vector-geoprocessing-dissolve, it is not working. I tried to select the polygons using same rule, then using "merge selected feature". However, the attributes value only following the first feature, meanwhile, I need the mean of each feature. Is there any way to merge the same category, and calculate the mean attributes value?

Best Answer

  1. Based on Uje Indo suggestion, I used field calculator to edit existing field "class" with this statement. It works perfectly.

CASE

WHEN "meanB0" < 12.5 AND "meanB3" < 85 THEN 'water'

WHEN "meanB0" > 12.5 AND "meanB0" <18 THEN 'nypa'

WHEN "meanB0" >= 17 AND "meanB7" > 170 THEN 'deadtree'

WHEN "meanB0" >=17 AND "meanB7" < 100 THEN 'rhizopora'

WHEN "meanB0" >=17 AND "meanB7" >= 100 AND "meanB7" <= 180 THEN 'bruguiera'

WHEN "meanB0" <=12.5 AND "meanB3" >= 85 THEN 'land'

END

  1. Based on Jochen Schwarze plus trial and error, I finally used saga dissolve polygon by attributes, it creates a shapefile with the class name only, and all other band information is gone. Afterward, to calculate mean,max,min etc for each class polygon, i have to:
    • split the raster image into each band using raster calculator
    • run saga grid statistic for polygon where for grids, choose all the raster band that split before, and for the shapefile choose the dissolve polygon. Run it, and the result will give a shp file with cell number, sum, range, min, max, mean, var, standard deviation for each band and each polygon.
Related Question