# 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')