Use Avenue to fill the NoData gaps left after mosaicking two or more grids together in ArcView


After merging or mosaicking grids in ArcView 3.x, there may be areas of no data cell values left between the grids. The following code sample will demonstrate how to fill these gaps.


The following code will use a FocalStats request in conjunction with a Con request to only change the NoData cell values. The FocalStats request will determine the new cell value by averaging the cell values in the neighborhood (NbrHood) around the NoData cells. Please see the ArcView Online Help documentation for specifics on these requests.

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into the new script window.

    theView = av.GetActiveDoc
    theGrid = theView.GetActiveThemes.Get(0).GetGrid
    theNbrHood = NbrHood.Make
    theNewGrid = (theGrid.IsNull).Con((theGrid.FocalStats(#GRID_STATYPE_MEAN,theNbrHood,FALSE)),theGrid)
    theGTheme = GTheme.Make(theNewGrid)

    Just in case the copy/paste applies some justification to the script, be sure the line beginning "theNewGrid" is complete. Otherwise, the code may not compile.

  3. Compile the code.
    [O-Image] Script compile button
  4. Arrange the desktop so the script and view windows are both visible.
  5. Click on the view and then make the merged (or mosaicked) theme active in the Table of Contents.
  6. Click directly back to script window and press the run button to execute the code.
    [O-Image] Run compiled script button
  7. Analyze the output and save to a permanent dataset if adequate.

    Depending on the data, modification of the neighborhood may be necessary. Vertical and horizontal gaps, odd terrain shapes or large gaps require different neighborhood matrices to get positive results. The default 3x3 matrix is used in this code.

Article ID:000005485

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic