I have an image


and I want to fill the empty spaces using the average of the neighbouring cells. I setNULL these values and followed Fill in NoData gaps in raster using ArcGIS for Desktop?

There was no change despite the code running.

I tried mosaicking with another raster and replaced the empty bit with Zeros

shown here.

How can then can I replace the zeros with the averages of the neighbours?


Use the Focal Statistics tool in the Spatial Analyst Toolbox. This tool will populate the evaluated cell with the descriptive statistic of your choice and give you roaming window shape and size options. Keep in mind that the output raster will have altered values in the areas that you do not want changed. In that case you could use a CON function on the original surface, and the focal stat surface to rebuild the raster you want.

| improve this answer | |
  • In the empty space that I want to fill, I want it based on the neighbouring cells only. Focal Statistics incorporates the values in the empty cell whether Nodata to calculate a new mean which is biased. the area can be directly spotted as "grey area" – Peter M Macharia Feb 6 '18 at 20:49

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.