I am aiming to write a tool in Arcpy that merges (mosaic) multiple raster files, fills the nodata cells (via gdal.FillNodata) and applies a hillshade to the raster. It is working fine but I want to optimize my script.

The raster files that are put in to the tool contain nodata cells that the tool fills with GDAL.FillNodata. However the sizes of area's that have these nodata 'gaps' vary a lot from raster to raster, so setting a maximum search distance (maxSearchDist) is quite a hassle. And for optimization purposes I don't want to set an extreme distance.

So my goal is to calculate the maximum cell distance of the biggest area with nodata cells within a set of raster files. And that'd be the input as my maxSearchDist. How would this be achieved? I am looking at raster calculations but I don't know whether to look for my answer in GDAL or Arcpy itself.

In the figure below I tried to visualize what I want to achieve. On the left is the raster file. From this raster I want to calculate which area of nodata cells is the largest and secondly (on the right indicated with the blue arrow) what the maximum distance of nodata cells is within that area. Visualization maxSearchDist

  • 1
    Can you add a screenshot showing what you want to measure? And you should probably pick either ArcGIS or gdal tag or your question might be closed as "to broad"/"needs more focus"
    – BERA
    Apr 10, 2020 at 17:50
  • 1
    @BERA I added a figure explaining what I would like to achieve. I removed the GDAL tag, thanks for the tip. Apr 10, 2020 at 19:27
  • Am I misunderstanding something, you simply want to turn cells that are NODATA into some specific value (e.g. -999)? As you say you can use arcpy, which implies ArcMap, why not use the ISNULL tool as part of a CON tool?
    – Hornbydd
    Apr 10, 2020 at 19:48
  • @Hornbydd No, I want the NODATA cells to be interpolated based on their surrounding cells. gdal.FillNodata does this via IDW. So far this seems to be the only tool that can fill large area's containting NODATA cells. The ISNULL tool only fills the cells with a given value. Apr 10, 2020 at 19:53
  • Ah OK did not know it could do that.
    – Hornbydd
    Apr 10, 2020 at 19:57

1 Answer 1


Here is one idea using ArcMap to compute your search distance to use in the GDAL.FillNodata tool:

  1. Run ISNULL to create a binary mask of your NODATA cells.
  2. Convert to polygons.
  3. As a crude estimate, return the envelopes (often referred to as minimum bounding boxes) and compute the diagonal.

This could all be done as a model or arcpy if you preferred?

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.