GeoEco.SpatialAnalysis.Interpolation.Interpolator.InpaintArcGISRaster
- classmethod Interpolator.InpaintArcGISRaster(inputRaster, outputRaster, method='Del2a', maxHoleSize=None, xEdgesWrap=False, minValue=None, maxValue=None, overwriteExisting=False)
Interpolates values for the NoData cells of a raster.
To run this tool, you either must have MATLAB R2026a or MATLAB Runtime R2026a installed. The MATLAB Runtime is free and may be downloaded from https://www.mathworks.com/help/compiler/install-the-matlab-runtime.html. Please follow the installation instructions carefully. Version R2026a must be used; other versions will not work. MATLAB Runtime allows multiple versions can be installed at the same time.
Use this tool to guess values for small clusters of NoData cells in rasters representing continuous surfaces, e.g. images of sea surface temperature in which cloudy pixels contain NoData. This tool provides several advantages over traditional moving-window methods provided by ArcGIS, such as the Focal Statistics tool of the ArcGIS Spatial Analyst:
It uses methods based on differential calculus that may provide more accurate guesses than traditional approaches, such as computing the focal mean of a 3x3 neighborhood.
It accurately handles rasters with global longitudinal extent, for which the east and west edges are connected.
It can fill NoData clusters of any size.
Although this tool can fill NoData clusters of any size, you should apply common sense when using it. The larger the cluster, the less accurate the guessed values will be, especially for rasters that represent a noisy surface.
This tool is implemented in MATLAB using the inpaint_nans function developed by John D’Errico. Many thanks to him for developing and sharing this function. Please see GeoEco’s LICENSE file for the relevant copyright statement.
Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later, MATLAB Runtime R2026a (which can be freely downloaded from https://www.mathworks.com/products/compiler/matlab-runtime.html) or the full version of MATLAB R2026a, Python numpy module, Python bindings for the Geospatial Data Abstraction Library (GDAL).
- Parameters:
inputRaster (
str) – Raster containing NoData cells to be filled. Minimum length꞉ 1. Must exist.outputRaster (
str) –The output raster will be identical to the input raster where the input raster has data. For cells of the input raster that do not have data, the output raster will contain values interpolated according to parameters of this tool.
If this is a file system path, missing directories in the path will be created.
Minimum length꞉ 1. Must be different than inputRaster.
method (
str, optional) –Method to use for interpolation and extrapolation of NoData values. One of:
Del2a- Performs Laplacian interpolation and linear extrapolation.Del2b- Same asDel2abut does not build as large a linear system of equations. May use less memory and be faster thanDel2a, at the cost of some accuracy. Use this method ifDel2afails due to insufficient memory or if it is too slow.Del2c- Same asDel2abut solves a direct linear system of equations for the NoData values. Faster than bothDel2aandDel2bbut is the least robust to noise on the boundaries of NoData cells and least able to interpolate accurately for smooth surfaces. Use this method ifDel2aandDel2bboth fail due to insufficient memory or are too slow.Del4- Same asDel2abut instead of the Laplace operator (also called the ∇2 operator) it uses the biharmoic operator (also called the ∇4 operator). May result in more accurate interpolations, at some cost in speed.Spring- Uses a spring metaphor. Assumes springs (with a nominal length of zero) connect each cell with every neighbor (horizontally, vertically and diagonally). Since each cell tries to be like its neighbors, extrapolation is as a constant function where this is consistent with the neighboring nodes.
Allowed values꞉
'Del2a','Del2b','Del2c','Del4','Spring'.maxHoleSize (
int, optional) – Maximum size, in cells, that a region of 4-connected NoData cells may be for it to be filled in. Use this option to prevent the filling of large NoData regions (e.g. large clouds in remote sensing images) when you are concerned that values cannot be accurately guessed for those regions. If this option is omitted, all regions will be filled, regardless of size. Must be greater than 0.xEdgesWrap (
bool, optional) – If True, the left and right edges of the raster are assumed to be connected and computations along those edges will consider the values on the opposite side of the raster.minValue (
float, optional) –Minimum allowed value to use when NoData cells are interpolated (or extrapolated). If this parameter is provided, all cells with less than the minimum value will be rounded up to the minimum. This includes not just the cells that had NoData in the original raster and were then interpolated or extrapolated, but also the cells that had values in the original raster.
Use this parameter when the interpolation/extrapolation algorithm produces impossibly low values. For example, consider a situation in which a chlorophyll concentration raster coincidentally shows a negative gradient approaching a cloud that straddles the edge of the raster. Missing pixels at the edge of the raster will be filled by extrapolation. If the negative gradient is strong enough, the algorithm might extrapolate negative concentrations for the cloudy pixels. This should be impossible; chlorophyll concentration must be zero or higher. To enforce that, you could specify a minimum value of zero (or a very small non-zero number, if exactly zero would be problematic, as might occur if the values were in a log scale).
maxValue (
float, optional) –Maximum allowed value to use when NoData cells are interpolated (or extrapolated). If this parameter is provided, all cells with greater than the maximum value will be rounded up to the maximum. This includes not just the cells that had NoData in the original raster and were then interpolated or extrapolated, but also the cells that had values in the original raster.
Use this parameter when the interpolation/extrapolation algorithm produces impossibly high values. For example, consider a situation in which a percent sea ice concentration raster shows a positive gradient approaching the coastline but does not provide data right up to shore. Say you wanted to fill the missing cells close to shore and were willing to assume that whatever gradient occurred nearby was reasonable for filling them in. If the positive gradient is strong enough, the algorithm might extrapolate ice concentration values greater than 100 percent, which is impossible. To prevent values from exceeding 100 percent, you could specify a maximum value of 100.
overwriteExisting (
bool, optional) – If True, the output raster will be overwritten, if it exists. If False, aValueErrorwill be raised if the output raster exists.