I was wondering if someone could help me write a majority filter for GRASS GIS. I have this map (see below) which I need to run a filter over to make the red areas a bit more dominant. I know I can use r.mapcalc but I'm just not sure of the formula.
Answer
The GRASS equivalent of a majority filter can be computed with the r.neighbors
command (help page). To get a simple majority filter, something like this should work, using a 3x3 window:
r.neighbors input=input_layer output=majority_filtered_output method=mode size=3
But r.neighbors supports many other options in addition to this. Depending on what you're trying to accomplish, you could also do this by taking the values of interest and classifying them into a new raster, then perform r.grow
on the raster, and merge that result back into your dataset.
No comments:
Post a Comment