Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

alt text

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.