Hello,
one of the raster files I base my weighted overlay analysis on has NODATA values or white spaces (see pictures). I would like to fill these holes with new cells with values corresponding to the cells surrounding them. I was a thinking maybe some kind of nearest neighbor method or create new cells based on the mean values from the surrounding cells. I found some method here in the forum where the tool "Con" was used, but I don't know how to correctly implement it. Are there other tools I can use or workflows with which I can fix my Raster?
Thank you in advance and best wishes
Daniel
Solved! Go to Solution.
Please check if a similar expression works for you using Raster Calculator?
Con(IsNull("raster"), FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEDIAN"), "raster")
You could change the 5,5 rectangle size to a bigger one (e.g. 9,9)
Hi Daniel2.
The Nibble tool from Spatial Analyst can be applied to your problem.
Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/nibble.htm
This tool allows specific areas of a raster to be replaced by the value of their nearest neighbour. These areas are defined by a mask input. In the mask input, cells that are NoData define which cells will be processed, or "nibbled away".
In your case, the areas you want to replace are already NoData, so you can actually just use the same dataset as both the input and the mask raster. You will just need to change one of the parameters from its default setting.
Run the Nibble tool as follows:
Starting out with your input here:
The result is:
Hopefully this will be a useful solution for you.
Of course, be mindful of how the results are used. The premise of using the nearest neighbour to a replace the value of an existing cell works well on a proximal basis. However, as the distances increase, the connection may become more tenuous, and the results more questionable.
Your example illustrates this point well. For the single cells and small clusters of cells, the new values in the output appear to be very reasonable. For the larger rectangular areas, this may not be the case.
Cheers,
Juan Laguna
Spatial Analyst Team
Please check if a similar expression works for you using Raster Calculator?
Con(IsNull("raster"), FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEDIAN"), "raster")
You could change the 5,5 rectangle size to a bigger one (e.g. 9,9)
Thank you so much! It worked really well. I was breaking my head about this!
Thank you very much
Hi Daniel2.
The Nibble tool from Spatial Analyst can be applied to your problem.
Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/nibble.htm
This tool allows specific areas of a raster to be replaced by the value of their nearest neighbour. These areas are defined by a mask input. In the mask input, cells that are NoData define which cells will be processed, or "nibbled away".
In your case, the areas you want to replace are already NoData, so you can actually just use the same dataset as both the input and the mask raster. You will just need to change one of the parameters from its default setting.
Run the Nibble tool as follows:
Starting out with your input here:
The result is:
Hopefully this will be a useful solution for you.
Of course, be mindful of how the results are used. The premise of using the nearest neighbour to a replace the value of an existing cell works well on a proximal basis. However, as the distances increase, the connection may become more tenuous, and the results more questionable.
Your example illustrates this point well. For the single cells and small clusters of cells, the new values in the output appear to be very reasonable. For the larger rectangular areas, this may not be the case.
Cheers,
Juan Laguna
Spatial Analyst Team
Hi Juan,
I'll try that method as well, thank you for the detailed answer! Yes I'm aware of the possible inaccuracies and will discuss that in my thesis. I think it won't be such a big issue tho. The data I'm using is the noise level of streets and in the shown hole areas are mostly buildings, so the noise "moves" rather linear from the streets to the surrounding areas.
Cheers
Daniel