Repair Geometry (Data Management) |
|
Release 9.3
Last modified March 8, 2012 |
![]() ![]() ![]() Print all topics in : "Tools" |
NOTE: This topic was updated for 9.3.1.
Inspects each feature's geometry for problems and fixes the problems that are found. Valid input formats are shapefile and feature classes stored in a personal geodatabase or file geodatabase. For more information, see Checking and repairing geometries.
ArcSDE geodatabases automatically check each geometry's validity when it is uploaded; therefore, the Check and Repair Geometry tools are not for use with ArcSDE geodatabases.
Usage tips
This tool uses the same logic as the Check Geometry tool, but when a geometry problem is discovered, the relevant fix (listed below) is applied.
This is the list of geometry problems and the fix that is applied by this tool:
After applying one of the repairs above, the tool will reevaluate the feature's geometry to see if it still has problems; if another problem is discovered, another repair will be performed immediately on that feature. This can lead to more than one fix being applied to a single feature.
Line features that are M aware will not be modified (repaired) for any of the cases above with these exceptions:
The following environment settings affect this tool: Extent and workspace.
Command line syntax
An overview of the Command Line window
RepairGeometry_management <in_features> {DELETE_NULL | KEEP_NULL}
Parameter | Explanation | Data Type |
<in_features> |
The feature class or layer that will have feature geometry problems repaired. If a layer is specified and that layer has a selection, only the selected features will be repaired. Valid input formats are shapefile and feature classes stored in a personal geodatabase or file geodatabase. |
Feature Layer |
{DELETE_NULL | KEEP_NULL} |
Specifies if action should be taken when features with NULL geometry are encountered.
|
Boolean |
RepairGeometry c:\myNewShapefiles\sketchy.shp"
Scripting syntax
About getting started with writing geoprocessing scripts
RepairGeometry_management (in_features, delete_null)
Parameter | Explanation | Data Type |
in_features (Required) |
The feature class or layer that will have feature geometry problems repaired. If a layer is specified and that layer has a selection, only the selected features will be repaired. Valid input formats are shapefile and feature classes stored in a personal geodatabase or file geodatabase. |
Feature Layer |
delete_null (Optional) |
Specifies if action should be taken when features with NULL geometry are encountered.
|
Boolean |
# RepairGeometryProblemList.py # Description: # Goes through the table generated by the Check Geometry tool. Runs the # Repair Geometry tool on the features which were identified as having # some geometry problem. # Requirements: Python and the Python win32all extension # Author: ESRI # Date 1/1/2004 # Create the Geoprocessor import arcgisscripting, os gp = arcgisscripting.create() # Table that was produced by Check Geometry tool table = "c:/data/badg.mdb/fc" # Create some variables dict = {} query = "" fieldName = "" # Loop through the table using a cursor rows = gp.searchCursor(table) row = rows.next() while row: # Get the class (feature class) for that row, as well as the Feature ID fc = row.GetValue("CLASS") fid = row.GetValue("FEATURE_ID") if not fieldName: # Determine which type feature class this is (Geodatabase or other) since how the field name # in the query is different for each fcType= gp.Describe(fc).DataType fieldName = gp.ListFields(fc, "*","FID").Next().Name if fcType == "FeatureClass": fieldName = "[" + fieldName + "]" # For Geodatabase, wrap the field name in [ ] elif fcType == "ShapeFile": fieldName = '"' + fieldName + '"' # For ShapeFiles, wrap the field name in " " else: raise Exception, "Repair Geometry does not support this format " + fcType # Create the query if query: query = query + " OR " + fieldName + " = " + str(fid) else: query = fieldName + " = " + str(fid) prevFc = fc row = rows.next() # Since there could be more than 1 CLASS in the table, separate each CLASS and its # associated query into entries in a Python dictionary if row: if fc <> row.GetValue("CLASS"): dict[prevFc] = query query = "" fieldName = "" else: dict[prevFc] = query query = "" fieldName = "" # Destroy the cursor object now that we're done with it del rows # Now loop through the dictionary and Make a layer with a definition query (so the Repair # Geometry is run only on those features with some problem) and run Repair Geometry on each. for fc in dict: try: gp.MakeFeatureLayer(fc, os.path.basename(fc),dict[fc]) gp.RepairGeometry(fc, r"c:\junk\outy.shp") except: print "Problem encountered attempting to repair " + fc print "FINISHED"