ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Repair Geometry

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Inspects each feature in a feature class for geometry problems. If a problem is found, it will be repaired 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 do not create output datasets for more information and strategies to avoid undesired data changes.

  • The tool will repair the following geometry problems:

    • 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 (delete_null = "KEEP_NULL" in Python).
    • 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.
  • After 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 Bad dataset extent problem cannot be repaired using this tool. To resolve this problem, run the Recalculate Feature Class Extent tool on the dataset.

  • Enterprise 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 enterprise feature classes is unnecessary.

Syntax

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

The feature class or layer to be processed.

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.
Boolean

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.

import arcpy
arcpy.RepairGeometry_management("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

  • Current Workspace
  • Extent

Licensing information

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

Related topics

  • An overview of the Features toolset
  • Checking and repairing geometries

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal