Geographic Information Systems Asked by Sabine on May 7, 2021
I have two global rasters and would like to expand one so that it matches the extent of the second by filling in NoData values with values taken from or averaged from nearby pixels. I have been using this expression in Raster Calculator in ArcGIS Pro:
Con(IsNull("fill_raster.tif")&"extent_raster.tif"==1, Int(FocalStatistics("fill_raster.tif", NbrCircle(15, "CELL"), "MEAN")), "fill_raster.tif")
This has been working to fill most of the small areas of NoData, but there are still larger or more isolated regions where there are no cells in the "fill_raster" with values, so using the circular neighborhood at a specified size does not reach them. In the image below, I am trying to fill the green areas with data from the grayscale raster, but some of these green areas had no cells with data within the circular neighborhood and remain NoData in the grayscale raster even after applying the focal statistics expression.
Is there a way to specify that the values should come from the nearest cells with data instead of any cells within the specified neighborhood size?
I'll first remove bits of terrain and will try to fill gaps:
Convert your green to integer of 1.
Define cost distance:
Expand_sa("GREEN", "../COST", "1", "1")
Find cells on the border, convert to points:
RasterCalculator_sa('"COST" * "ERASED"', "..BOUNDARY")
RasterToPoint_conversion("BOUNDARY","../boundary_points")
Allocate missing areas to nearest point on the boundary, open it's table and transfer values from boundary points:
CostAllocation_sa("boundary_points", "COST", "../ALLOCATION", "", "", "OBJECTID")
MakeTableView_management("ALLOCATION", "ALLOCATION_View")
JoinField_management("ALLOCATION_View", "Value", "boundary_points", "OBJECTID", fields="grid_code")
Fill missing areas:
Lookup_3d("ALLOCATION", "grid_code", ".../LOOKUP")
RasterCalculator_sa('Con(IsNull("ERASED"),"LOOKUP","ERASED")', "../COMBO")
OUTPUT:
Smooth what I called Lookup before merging with original.
Correct answer by FelixIP on May 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP