Fill Gaps (Topographic Production)

Summary

Fills gaps between polygon features that participate in a topology where the coincident boundaries are evident.

Many types of polygon features should have coincident boundaries with other features. Coincident boundaries can be important for features in a single polygon feature class, such as parcels, or between features in different feature classes, such as lakes and surrounding vegetation. A gap between the features exists when there is space between the boundaries of two or more features.

Illustration

Fill Gaps tool illustration

Usage

    Caution:

    This tool modifies the input data. See Tools that modify or update the input data for more information and strategies to avoid undesired data changes.

  • This tool requires one or more input feature classes. If only one input feature class is specified, the tool searches for gaps between individual features in that feature class. When multiple feature classes are specified, the tool searches for gaps between all features in all the input feature classes. The tool can find gaps between two features in the same feature class as well as gaps between features in any of the feature classes.

  • When multiple feature layers are provided and the Fill Options parameter is set to Fill By Length, the area of the gap is added to the feature class that shares the longest boundary with the gap. For instance, if a gap shares a longer boundary with vegetation features and a shorter boundary with lake features, the area of the gap is added to the feature in the vegetation layer.

  • The order of the inputs in the Input Features parameter list is important when the Fill Options parameter is set to Fill By Order. For instance, if vegetation is first in the list and lakes are the second input polygons when Fill By Order is chosen, the vegetation features are always adjusted to fill the gap.

  • When searching for gaps between features in multiple feature classes, add all of the feature classes as input polygons. For example, if there should be no gaps between features in the lakes, grass, and forest feature classes, add them to the Input Features parameter. If you add only lakes and forests, the tool can identify a gap between lakes and forests and fill the gap. However, the area that was identified as a gap may have had a grass feature, which results in the modified feature overlapping the grass. To prevent overlaps, add all relevant feature classes to the Input Features parameter.

  • Unenclosed gaps exist when two polygon boundaries are within a specified distance of each other. The two polygon features do not have to touch each other at any point.

  • When the Fill Unenclosed Gaps parameter is checked, the unenclosed gaps are filled first. Enclosed gaps are filled after unenclosed gaps are filled.

  • Enclosed gaps exist when there are gaps between two polygon boundaries.

  • This tool fills holes in a single feature but does not fill unenclosed gaps between the edges of a single feature. If a feature is a multipart feature, the gaps between the parts are not filled. If a feature curves and different parts of the edge are close to each other creating small gaps, the gaps along the edge are not filled.

Parameters

LabelExplanationData Type
Input Features

A list of input polygon feature classes or layers to be analyzed for gaps.

Feature Layer
Maximum Gap Area

The maximum area that can be considered a gap. Areas larger than this threshold are not filled.

Areal Unit
Fill Option
(Optional)

Specifies how enclosed and unenclosed gaps are filled.

  • Fill By Length —Gaps are filled by adding a gap's geometry to the polygon with the longest shared edge. This is the default.
  • Fill By Order —Gaps are filled sequentially according to the order of the input polygon features list.
String
Fill Unenclosed Gaps
(Optional)

Specifies whether the tool fills unenclosed gaps.

  • Unchecked—Only enclosed gaps are filled. Unenclosed gaps are skipped. This is the default.
  • Checked—Both enclosed and unenclosed gaps are filled.
Boolean
Maximum Gap Distance
(Optional)

The maximum distance between features in which a gap can be filled. This parameter is used only when the Fill Unenclosed Gaps parameter is checked.

Linear Unit

Derived Output

LabelExplanationData Type
Updated Features

The updated feature classes and layers after removing gaps.

Feature Layer

arcpy.topographic.FillGaps(input_features, max_gap_area, {fill_option}, {fill_unenclosed_gaps}, {max_gap_distance})
NameExplanationData Type
input_features
[input_features,...]

A list of input polygon feature classes or layers to be analyzed for gaps.

Feature Layer
max_gap_area

The maximum area that can be considered a gap. Areas larger than this threshold are not filled.

Areal Unit
fill_option
(Optional)

Specifies how enclosed and unenclosed gaps are filled.

  • FILL_BY_LENGTHGaps are filled by adding a gap's geometry to the polygon with the longest shared edge. This is the default.
  • FILL_BY_ORDERGaps are filled sequentially according to the order of the input polygon features list.
String
fill_unenclosed_gaps
(Optional)

Specifies whether the tool fills unenclosed gaps.

  • SKIP_UNENCLOSED_GAPSOnly enclosed gaps are filled. Unenclosed gap are skipped. This is the default.
  • FILL_ALLBoth enclosed and unenclosed gaps are filled.
Boolean
max_gap_distance
(Optional)

The maximum distance between features in which a gap can be filled. This parameter is used only when the fill_unenclosed_gaps parameter is set to FILL_ALL.

Linear Unit

Derived Output

NameExplanationData Type
updated_features

The updated feature classes and layers after removing gaps.

Feature Layer

Code sample

FillGaps example 1 (stand-alone script)

The following stand-alone script demonstrates how to use the FillGaps function to eliminate the spaces between enclosed polygon features.

# Name: FillGaps_sample1.py
# Description: The Fill Gaps tool eliminates the spaces between polygon features. The following stand-alone 
# sample script demonstrates how to use Fill Gaps for enclosed features.

# Import System Modules
import arcpy

# Check Out Extensions
arcpy.CheckOutExtension('Foundation')

# Setting the environment
arcpy.env.overwriteOutput = True

# Setting Local Variables
inPoly1 = r'C:\data\SaltLakeCity.gdb\CTM\SettlementSrf'
inPoly2 = r'C:\data\SaltLakeCity.gdb\CTM\HydrographySrf'
inPoly3 = r'C:\data\SaltLakeCity.gdb\CTM\VegetationSrf'
max_gap_area = '700000 SquareMeters'
fill_option = 'FILL_BY_LENGTH'
fill_unenclosed_gaps = 'SKIP_UNENCLOSED_GAPS'

# Create feature layer for input features
arcpy.MakeFeatureLayer_management(inPoly1,'inSettlementSrfLyr')
arcpy.MakeFeatureLayer_management(inPoly2,'inHydrographySrfLyr')
arcpy.MakeFeatureLayer_management(inPoly3,'inVegetationSrfLyr')

# Calling Fill Gaps to eliminate enclosed spaces between SettlementSrf, HydrographySrf, and VegetationSrf features
arcpy.FillGaps_topographic('inSettlementSrfLyr;inHydrographySrfLyr;inVegetationSrfLyr', max_gap_area, fill_option, fill_unenclosed_gaps)

# Getting all messages, warnings, and errors from the tool run and printing the results back to the user
messages = arcpy.GetMessages(0)
warnings = arcpy.GetMessages(1)
errors = arcpy.GetMessages(2)
arcpy.AddMessage('Tool Messages: {}\nTool Warnings: {}\nTool Errors{}\n'.format(messages, warnings, errors))

# Check In Extensions
arcpy.CheckInExtension('Foundation')
FillGaps example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the FillGaps function to eliminate the spaces between unenclosed polygon features.

# Name: FillGaps_sample2.py
# Description: The Fill Gaps tool eliminates the spaces between polygon features. The following stand-alone 
# sample script demonstrates how to use Fill Gaps for unenclosed features.

# Import System Modules
import arcpy

# Check Out Extensions
arcpy.CheckOutExtension('Foundation')

# Setting the environment
arcpy.env.overwriteOutput = True

# Setting Local Variables
inPoly1 = r'C:\data\SaltLakeCity.gdb\CTM\SettlementSrf'
inPoly2 = r'C:\data\SaltLakeCity.gdb\CTM\HydrographySrf'
inPoly3 = r'C:\data\SaltLakeCity.gdb\CTM\VegetationSrf'
max_gap_area = '700000 SquareMeters'
fill_option = 'FILL_BY_LENGTH'
fill_unenclosed_gaps = 'FILL_ALL'
max_gap_distance = '20 Meters'

# Create feature layer for input features
arcpy.MakeFeatureLayer_management(inPoly1,'inSettlementSrfLyr')
arcpy.MakeFeatureLayer_management(inPoly2,'inHydrographySrfLyr')
arcpy.MakeFeatureLayer_management(inPoly3,'inVegetationSrfLyr')

# Calling Fill Gaps to eliminate enclosed and unenclosed spaces between SettlementSrf, HydrographySrf, and VegetationSrf features
arcpy.FillGaps_topographic('inSettlementSrfLyr;inHydrographySrfLyr;inVegetationSrfLyr', max_gap_area, fill_option, fill_unenclosed_gaps, max_gap_distance)

# Getting all messages, warnings, and errors from the tool run and printing the results back to the user
messages = arcpy.GetMessages(0)
warnings = arcpy.GetMessages(1)
errors = arcpy.GetMessages(2)
arcpy.AddMessage('Tool Messages: {}\nTool Warnings: {}\nTool Errors{}\n'.format(messages, warnings, errors))

# Check In Extensions
arcpy.CheckInExtension('Foundation')

Environments

Licensing information

  • Basic: No
  • Standard: No
  • Advanced: Requires Production Mapping

Related topics