Repair Geometry (Data Management)
Inspects each feature in a feature class for geometry problems. Upon discovery of a geometry problem, a relevant fix will be applied, and a one line description will be printed identifying the feature as well as the problem encountered.
Valid inputs are shapefiles, personal and file geodatabase feature classes.
This tool uses the same logic as the Check Geometry tool to evaluate if a geometry has a problem.
Below is the list of geometry problems and the corresponding fix that will be performed by the tool:
- Null geometry: The record will be deleted from the feature class. To keep records with null geometry, uncheck the tool dialog option Delete Features with Null Geometry, or in scripting set the delete_null parameter to KEEP_NULL.
- Short segment: The geometry's short segment will be deleted.
- Incorrect ring ordering: The geometry will be updated to have correct ring ordering.
- Incorrect segment orientation: The geometry will be updated to have correct segment orientation.
- Self intersections: the areas of overlap in a polygon will be dissolved.
- Unclosed rings: The unclosed rings will be closed by connecting the ring's end points.
- Empty parts: The parts that are null or empty will be deleted.
- Duplicate vertex: One of the vertices will be deleted.
- Mismatched attributes: The Z or M coordinate will be updated to match.
- Discontinuous parts: Multiple parts will be created from the existing discontinuous part.
- Empty Z values: The Z value will be set to 0.
SDE geodatabases automatically check and repair feature geometries when the features are uploaded to the database, so using the Check Geometry and Repair Geometry tools with SDE feature classes is unnecessary.
After applying one of the repairs above, the tool will re-evaluate the resulting geometry, and if another problem is discovered, the relevant fix will be performed.
Starting with the 10.0 release, a line geometry is no longer considered "self-intersecting" if it crosses itself. There was no adverse effect to these types of geometry therefore the Check Geometry tool will no longer report the feature as a problem, and the Repair Geometry tool will no longer perform a "fix" on the feature's geometry. Prior to the 10.0 release Repair Geometry would add vertices at the point of intersection of "self-intersecting" lines. If you do want to add vertices when line features intersect themselves use the Integrate tool.
This tool modifies the input data. See Tools with no outputs for more information and strategies to avoid undesired data changes.
The feature class or layer that will be repaired. Valid input features are shapefiles and personal and file geodatabase feature classes.
Specifies what action to take on null geometries.
The following Python Window script demonstrates how to use the RepairGeometry function in immediate mode.
import arcpy arcpy.RepairGeometry_management ("c:/data/sketchy.shp")
The following stand-alone script is an example of how to apply the RepairGeometry function in scripting.
# Description: # Goes through the table generated by the Check Geometry tool and does # the following # 1) backs-up all features which will be acted upon to a "_bad_geom" feature class # 2) runs repairGeometry on all feature classes listed in the table import arcpy import os # Table that was produced by Check Geometry tool table = r"c:\temp\f.gdb\cg_sample1" # Create local variables fcs =  prevFc = "" # Loop through the table and get the list of fcs for row in arcpy.SearchCursor(table): # Get the class (feature class) for that row fc = row.getValue("CLASS") if fc != prevFc: prevFc = fc fcs.append(fc) # Now loop through the fcs list, backup the bad geometries into fc + "_bad_geom" # then repair the fc print "> Processing %i feature classes" % len(fcs) for fc in fcs: print "Processing " + fc lyr = os.path.basename(fc) if arcpy.Exists(lyr): arcpy.Delete_management(lyr) tv = "cg_table_view" if arcpy.Exists(tv): arcpy.Delete_management(tv) arcpy.MakeTableView_management(table, tv, ("\"CLASS\" = '%s'" % fc)) arcpy.MakeFeatureLayer_management(fc, lyr) arcpy.AddJoin_management(lyr, arcpy.Describe(lyr).OIDFieldName, tv, "FEATURE_ID") arcpy.CopyFeatures_management(lyr, fc + "_bad_geom") arcpy.RemoveJoin_management(lyr, os.path.basename(table)) arcpy.RepairGeometry_management(lyr)