0

I have the following raster layer that has data gaps. I can use focal statistics to fill them:

Con(IsNull("raster"), FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEAN"), "raster")

However, I want to use a zonal layer and limit the neighbors based on that layer so that the function only uses the mean of all the neighboring values that are in the same zone. enter image description here

4
  • Did you look at Focal statistics, with Irregular neighborhood settings? I am thinking the zonal boundaries could be provided through the kernel file specification, but I am not sure how the kernel file is specified. It is worth looking at.
    – yanes
    Commented Dec 30, 2015 at 19:39
  • I just looked at it. I can't use my zonal file as the kernel.
    – Geo-sp
    Commented Dec 30, 2015 at 19:56
  • From ArcGIS help, the kernel file is provided as an ascii file that contains 0s and 1s defining neighborhood. It is not a simple work around, if anything else fails, you can convert your zones into raster files - and interpolate your raster one zone at a time by setting all the regions of other zones to zero and the zone that is calculated to 1 in the kernel ascii file. ( A loop can be used to automate the focal analysis using different kernel files). I hope you find an easier way though.
    – yanes
    Commented Dec 30, 2015 at 20:04
  • Before you do a lot of extra work.Did you look at setting the set mask environmental setting while doing your focal analysis? If you set your environmental settings to the processing extent and raster mask to your zone (this needs to be done zone by zone too) while doing your focal analysis it might work out. if you don't have to many zones, you can then mosaic/merge the different raster regions interpolated by zones. I found similar solution proposed and accepted here on GIS SE.
    – yanes
    Commented Dec 30, 2015 at 20:20

1 Answer 1

2
  1. Save your zones individually (using definition query then export feature), This should give you as many masks as the number of your zones.

  2. Do your focal analysis one by one, each time using a different zone as the processing extent and mask in the environmental settings- save your raster with corresponding id that matches the zone used.

  3. Mosaic/merge the output rasters.

Note : Both processing extent and mask has to be set to the zone being processed. Masks are only applied after the interpolation, therefore, if the processing extent is not set, the values might be interpolated from the whole data before masking.

2
  • 1
    Thanks that worked well! I used this code: Con(IsNull("raster")& "zone==1", FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEAN"), "raster")
    – Geo-sp
    Commented Dec 30, 2015 at 20:37
  • great! I wasn't happy with the irregular kernel definition solution.
    – yanes
    Commented Dec 30, 2015 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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