How To: 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.
- Open a new script window. A. Activate the Project window.
B. Click the Scripts icon.
C. Click New.
- 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.
- Compile the code.
- Arrange the desktop so the script and view windows are both visible.
- Click on the view and then make the merged (or mosaicked) theme active in the Table of Contents.
- Click directly back to script window and press the run button to execute the code.
- 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.