Repair Geometry (Data Management)

Summary

Inspects features for geometry problems and repairs them. If a problem is found, a repair will be performed, and a one-line description will identify the feature, as well as the geometry problem that was repaired.

This tool uses the same logic as the Check Geometry tool to repair geometry problems.

Learn more about checking and repairing geometries

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.

  • Valid input formats are shapefiles, and feature classes stored in a file geodatabase, enterprise database, enterprise geodatabase, GeoPackage, or SpatiaLite database. For feature classes stored in an enterprise database or enterprise geodatabase, the following spatial types are supported:

    • Microsoft SQL Server—Geometry and Geography
    • PostgreSQLPostGIS, Geometry, and Geography
    • Oracle—SDO_Geometry
    • SAP HANA—ST_Geometry

    License:

    A Desktop Basic license allows you to apply this tool to only shapefiles and feature classes stored in a file geodatabase, GeoPackage, or SpatiaLite database. A Desktop Standard or Desktop Advanced license allows you to also apply this tool to feature classes stored in an enterprise database or enterprise geodatabase.

  • Feature classes that are stored in an enterprise geodatabase and registered as versioned are not supported.

  • The Enable Undo toggle button is not valid for inputs from an enterprise geodatabase.

  • Below is the list of geometry problems and the corresponding repair 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 Delete Features with Null Geometry parameter.
    • Short segment—The geometry's short segment will be deleted.
    • Incorrect ring ordering—The geometry will be updated with the correct ring ordering.
    • Incorrect segment orientation—The geometry will be updated with the 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 end points of the rings.
    • 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.
    • Bad envelope—The feature's envelope will be updated to be correct.
    • Bad dataset extent—The feature class extent will be updated to be correct.

    Below is the list of geometry problems that may occur from data stored in an enterprise geodatabase and the corresponding repair (if one exists) that will be performed by the tool:

    • NEEDS_REORDERING—The shape will be reordered and duplicate points will be removed.
    • SE_INVALID_ENTITY_TYPE—The entity type will not be repaired (the feature must be deleted).
    • SE_SHAPE_INTEGRITY_ERROR—The shape may not be repaired.
    • SE_INVALID_SHAPE_OBJECT—The shape object may not be repaired.
    • SE_COORD_OUT_OF_BOUNDS—The coordinate will not be repaired.
    • SE_POLY_SHELLS_OVERLAP—Overlapping shells will be merged.
    • SE_TOO_FEW_POINTS—The points will not be repaired.
    • SE_INVALID_PART_SEPARATOR—The part separator may not be repaired.
    • SE_INVALID_POLYGON_CLOSURE—Unclosed shells will be discarded (the resulting polygon may be left empty).
    • SE_INVALID_OUTER_SHELL—An attempt to repair the feature's outer shells will be made; shells may be discarded in the process.
    • SE_ZERO_AREA_POLYGON—The polygon will be converted to an empty shape.
    • SE_POLYGON_HAS_VERTICAL_LINE—The vertical line will be removed (the shape may be converted to 2D).
    • SE_OUTER_SHELLS_OVERLAP—Overlapping parts will be merged.
    • SE_SELF_INTERSECTING—Intersection points will be added as needed.

    Note:

    Some problems associated with data stored in an enterprise database may not be repairable with ArcGIS tools.

  • After performing a repair, the tool will reevaluate the resulting geometry and if another problem is found, the relevant repair will be performed for that problem. For example, the result of repairing a geometry with the Incorrect ring ordering problem may be a geometry with the Null geometry problem.

  • The Esri validation option ensures that geometry is topologically correct using the Esri Simplify method. Only the Esri validation is available for data stored in an enterprise geodatabase.

  • The Open Geospatial Consortium (OGC) validation method ensures that geometry complies with the OGC specification as defined in OpenGIS Implementation Standard for Geographic information – simple feature access – Part 1: common architecture.

  • After a feature's geometry is repaired using the OGC option, any subsequent edit or modification may cause the geometry to no longer comply with the OGC specification.

    After feature modification, run the Check Geometry tool to check for new geometry issues. If necessary, rerun the Repair Geometry tool.

  • Geometry that is validated or repaired using the OGC option will be valid for the Esri option. To learn more about both methods, see What is a simple polygon.

Parameters

LabelExplanationData Type
Input Features

The feature class or layer to be processed.

License:

A Desktop Basic license only allows shapefiles and feature classes stored in a file geodatabase, GeoPackage, or SpatiaLite database as valid input feature formats. A Desktop Standard or Desktop Advanced license also allows feature classes stored in an enterprise database or enterprise geodatabase to be used as valid input feature formats.

Feature Layer
Delete Features with Null Geometry
(Optional)

Specifies whether features with null geometries will be deleted.

  • Checked—Features with null geometry will be deleted from the input. This is the default.
  • Unchecked—Features with null geometry will not be deleted from the input.

Note:
Delete null is not available for data stored in an enterprise database, enterprise geodatabase, GeoPackage, or SpatiaLite database.

Boolean
Validation Method
(Optional)

Specifies the geometry validation method that will be used to identify geometry problems.

  • EsriThe Esri geometry validation method will be used. This is the default.
  • OGCThe OGC geometry validation method will be used.
String

Derived Output

LabelExplanationData Type
Repaired Input Features

The updated input features.

Feature Layer

arcpy.management.RepairGeometry(in_features, {delete_null}, {validation_method})
NameExplanationData Type
in_features

The feature class or layer to be processed.

License:

A Desktop Basic license only allows shapefiles and feature classes stored in a file geodatabase, GeoPackage, or SpatiaLite database as valid input feature formats. A Desktop Standard or Desktop Advanced license also allows feature classes stored in an enterprise database or enterprise geodatabase to be used as valid input feature formats.

Feature Layer
delete_null
(Optional)

Specifies whether features with null geometries will be deleted.

  • DELETE_NULL Features with null geometry will be deleted from the input. This is the default.
  • KEEP_NULL Features with null geometry will not be deleted from the input.

Note:
Only KEEP_NULL is valid for inputs from an enterprise database, enterprise geodatabase, GeoPackage, or SpatiaLite database.

Boolean
validation_method
(Optional)

Specifies the geometry validation method that will be used to identify geometry problems.

  • ESRIThe Esri geometry validation method will be used. This is the default.
  • OGCThe OGC geometry validation method will be used.
String

Derived Output

NameExplanationData Type
out_feature_class

The updated input features.

Feature Layer

Code sample

RepairGeometry example 1 (Python window)

The following Python window script demonstrates how to use the RepairGeometry function in immediate mode on a shapefile.

import arcpy
arcpy.management.RepairGeometry("c:/data/sketchy.shp")
RepairGeometry example 2 (stand-alone script)

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 'fixed' 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\data.gdb\cg_sample1"
 
# Create local variables
fcs = []
 
# Loop through the table and get the list of fcs
for row in arcpy.da.SearchCursor(table, ("CLASS")):
    # Get the class (feature class) from the cursor
    if not row[0] in fcs:
        fcs.append(row[0])
 
# Now loop through the fcs list, backup the bad geometries into fc + "_bad_geom"
# then repair the fc
print("> Processing {0} feature classes".format(len(fcs)))
for fc in fcs:
    print("Processing " + fc)
    lyr = 'temporary_layer'
    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)

Environments

Special cases

Parallel Processing Factor

If the environment is not set (the default) or is set to 0, parallel processing will be disabled. If set to 100, the tool will attempt to distribute the work to all the logical cores on the machine. Specifying a factor between 1 and 99 will cause the tool to identify the percentage of logical cores to use by applying the formula (Parallel Processing Factor / 100 * Logical Cores) rounded up to the nearest integer. If the result of this formula is 0 or 1, parallel processing will not be enabled.

Licensing information

  • Basic: Limited
  • Standard: Yes
  • Advanced: Yes

Related topics