Repair Geometry (Data Management) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
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. SDE Geodatabases automatically check each geometry's validity when it is uploaded, therefore the Check and Repair Geometry tools are not for use with SDE.
Usage tips
The Check Geometry tool can be used to identify feature classes and features within those feature classes that have geometry problems.
This tool uses the same logic as the Check Geometry tool, but when a geometry problem is discovered, a fix (listed below) is applied immediately.
Problems repaired with this tool:
After applying one of the repairs above, the tool will re-evaluate the feature's geometry to see if it still has a 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 unless they are short segments or null geometry.
The following environment setting affects this tool: Extent and workspace.
Command line syntax
An overview of the Command Line window
RepairGeometry_management <in_features>
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 |
RepairGeometry c:\myNewShapefiles\sketchy.shp"
Scripting syntax
About getting started with writing geoprocessing scripts
RepairGeometry_management (in_features)
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 |
# 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 # Data 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 it's # 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"