1

I have a raster layer has values +1, -1, and zero. Now I want to select those pixels whose value is zero and assign them new values based on the majority of its neighbor 5*5 cells. Is there anyway that I can do this? Thanks.

I've tried focal statistics but it is not exactly I want.

1

I think what you need is a two-step process.

  1. Run Focal Statistics, using MAJORITY as the statistics type. The resulting raster (let's call it's FocStat) will be used for reference.
  2. Run Raster Calculator (Map Algebra) to filter so only cells that were originally zero will use the Focal Statistics result. Raster calculator expression: Con(YourRaster == 0, FocStat, YourRaster)

    Alternatively you can use the Con tool, using the original raster (YourRaster) as the true condition, FocStat as the false condition, and Value == 0 as the condition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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