# Fill (Spatial Analyst)

## Summary

Fills sinks in a surface raster to remove small imperfections in the data.

## Usage

• A sink is a cell with an undefined drainage direction; no cells surrounding it are lower. The pour point is the boundary cell with the lowest elevation for the contributing area of a sink. If the sink were filled with water, this is the point where water would pour out.

• The z-limit specifies the maximum depth of a sink that will be filled. The z-limit is not the maximum depth to which a sink will be filled. Z-limit must be greater than zero.

• All sinks that are less than the z-limit, lower than their lowest adjacent neighbor, will be filled to the height of their pour points.

• Due to the iterative nature of Fill, it can be CPU and disk intensive. It can require up to four times the disk space of the input raster.

• The number of sinks found with the z-limit will determine the length of processing time. The more sinks, the longer the processing time.

• The Sink tool can be used to find the number of sinks and help identify their depth. Knowing the depth of the sinks can help in determining an appropriate z-limit for Fill.

• Fill can also be used to remove peaks. A peak is a cell where no adjacent cells are higher. To remove peaks, the input surface raster must be inverted. This can be performed with the Minus tool. Specify the highest value of the surface raster as the first input to Minus and surface raster as the second input. Perform a Fill. Invert the results to obtain a surface that has original surface raster values with the peaks removed. The z-limit can be applied to this process as well. If nothing is specified for z-limit, then all peaks will be removed. If it is specified, where the difference in z-value between a peak and its highest adjacent neighbor is greater than the z-limit, that peak will not be removed.

## Syntax

Fill (in_surface_raster, {z_limit})
 Parameter Explanation Data Type in_surface_raster The input raster representing a continuous surface. Raster Layer z_limit(Optional) Maximum elevation difference between a sink and its pour point to be filled.If the difference in z-values between a sink and its pour point is greater than the z_limit that sink will not be filled.The default is to fill all sinks, regardless of depth. Double

#### Return Value

 Name Explanation Data Type out_surface_raster The output surface raster after the sinks have been filled. Raster

## Code Sample

Fill example 1 (Python window)

This example fills the sinks of an input elevation surface GRID raster.

```import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outFill = Fill("elevation")
outFill.save("C:/sapyexamples/output/outfill01")
```
Fill example 2 (stand-alone script)

This example fills the sinks of an input elevation surface GRID raster with a z-limit applied.

```# Name: Fill_Ex_02.py
# Description: Fills sinks in a surface raster.
# Requirements: Spatial Analyst Extension
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inSurfaceRaster = "elevation"
zLimit = 3.28

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute FlowDirection
outFill = Fill(inSurfaceRaster, zLimit)

# Save the output
outFill.save("C:/sapyexamples/output/outfill02")
```

## Licensing Information

ArcView: Requires Spatial Analyst
ArcEditor: Requires Spatial Analyst
ArcInfo: Requires Spatial Analyst

6/29/2011