Majority Filter algorithm when majority of neighbors have NoData

1230
2
04-30-2014 02:04 PM
MarilynDaum
New Contributor
I'm trying to understand how the Majority Filter tool works around the edges and in sparse areas, where most of the neighboring cells have NoData value.  I have my filter set to use EIGHT neighbors, with replacement on MAJORITY.  If only 1 of the 8 neighbors has a value, the cell is replaced by NoData.  However, if 2 or 3 of the cell's neighbors have values (and all the same value), and the remaining 5 or 6 neighbors have NoData, then the cell seems to be replaced by the existing neighbor values.  There is obviously some nuance in the algorithm that's not clear to me from the online documentation.  Can someone explain this?

FWIW, I encountered this going thru the site selection tutorial that comes with the Spatial Analyst package.

Thanks.
0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor
I'm trying to understand how the Majority Filter tool works around the edges and in sparse areas, where most of the neighboring cells have NoData value.  I have my filter set to use EIGHT neighbors, with replacement on MAJORITY.  If only 1 of the 8 neighbors has a value, the cell is replaced by NoData.  However, if 2 or 3 of the cell's neighbors have values (and all the same value), and the remaining 5 or 6 neighbors have NoData, then the cell seems to be replaced by the existing neighbor values.  There is obviously some nuance in the algorithm that's not clear to me from the online documentation.  Can someone explain this?

FWIW, I encountered this going thru the site selection tutorial that comes with the Spatial Analyst package.

Thanks.


I kind of agree that one does not make a majority. This behavior is documented here, for a related tool: How Focal Statistics Works:

When there is more than one majority value within a neighborhood, the processing cell location will receive NoData on the output.


For your use case, it may make sense to convert the null values to a NoData cell code first. For example, in Raster Calculator:

MajorityFilter(Con(IsNull("inraster"), 9999, "inraster"), "MAJORITY")

If you get a majority NoData, you you could then set those back to NoData:

SetNull("filt_raster" == 9999, "filt_raster")
0 Kudos
MarilynDaum
New Contributor
Thanks.  After considering your response and looking into it more, I figured out my problem; it's a matter of perspective, and reading the fine print: NoData is a value, and replacement occurs only if the cells are contiguous.  Beginner's error, I think.
0 Kudos