I have two raster layer, one showing land use and another showing mean species abundance. I want to find out the MSA for the individual land uses so have made new layers with the individual land use types but i am unable to find the MSA. How can i get the MSA using QGIS?
1 Answer
First, check to see if the Raster Layer Zonal Statistics algorithm in the processing toolbox will achieve what you need, with the land use categories defining the zones.
Otherwise, as a first step, you will probably want to create layers which show the MSA but only at points with a specific land use. This operation is called masking.
If you're using QGIS 3.22+, the simplest way to do this is using the raster calculator 'if()' function. The formula will look something like
if("Land Use@1"=1,"MSA@1",-1)
This is a stab in the dark since don't know precisely your layer names or data types. It assumes Land Use has integer values and 1 is the land use value you are after in this masked copy. And it uses -1 as a fake NODATA value for MSA; you may need to change this. If you have QGIS <3.22, see Writing Conditional Statements in QGIS raster calculator for how to fake it with multiplication and logical operators.
Then you need to tell QGIS -1 (or whatever) is NODATA value in the layer properties for the output layer.
You can then do any processing or display you need on each masked layer for each land use value.
Finally, if you will be doing this systematically or algorithmically, you may want to automate this. QGIS' treatment of NODATA values, which are integral to what you're doing (if not just using zonal statitics), is a bit kludgy. In this case, you might do better if you have any programming skills to do your work in Grass or in R and then just display your outputs in QGIS.