I am looking at classifying an image to identify crop types.
I am interested in masking out all other landcover classes except crop class in the band stack false colour composite image e.g. buildings, roads, water, cloud,… in QGIS.
How would I go about this?
(a) classify the image, convert classes from raster to vector and clip the raster image to the vegetation vector polygon
or
(b) mask out the pixels using band math where by the pixel values for the unwanted classes are equaled to 0
I think both of these should theoretically work (apart from risk of pixel misclassification in approach (a) and an issue whereby the layer stack cannot be chosen as a source file in approach (b).
Best Answer
I think the proper way to extract only the vegetation/cropland cover is to do the following:
If you want the output as raster image to keep only the vegetation/cropland cover and mask other classes, you can use the following expression in
QGIS Raster Calculator
: