Select to view content in your preferred language

Python Create and Cleanup Topology

3201
3
03-23-2011 01:14 PM
MichaelGartrell
Emerging Contributor
I need some help getting started.  What I want to script is

  1. define some simple topology rules for a single dataset (must not have gaps, must not overlap self),

  2. validate the topology,

  3. step through each error and apply an automatic fix depending on the type of error (as from the context menu when viewing topo errors in ArcMap)

Can this be done?  Can someone point me to some examples, documentation, etc?  I've looked and all I can find is a posting about deleting existing topology (like http://forums.arcgis.com/threads/21947-Can-a-topology-rule-in-a-personal-geodatabase-be-deleted-usin...).

Thanks.

Michael.
Tags (2)
0 Kudos
3 Replies
BillBass
Deactivated User
Yes, you can. Here are some sample scripts we use in a Python batch program. However, I have yet to find a method to extract the value that are displayed in the Generate Summary after the topology has been validated. I have seem a couple of other posts on the same topic, but no responses.

import arcpy

Scratch_Workspace = "G:\\CE\\Forecast\\Parcels_2008_2010\\Parcels_Scratch.gdb"
arcpy.env.workspace= Scratch_Workspace
arcpy.env.overwriteOutput= "True"

#Creates Feature Dataset and loads dataset into feature dataset
arcpy.CreateFeatureDataset_management(Scratch_Workspace,"Parcels_Topology","Parcels_Overlay_WD_Dissolved")

arcpy.Select_analysis("Parcels_Overlay_WD_Dissolved","Parcels_Topology\\Parcels_Dissolved","")

#Creates topology and adds loaded dataset to topology and assigns rule
arcpy.CreateTopology_management("Parcels_Topology","Parcels_Dissolved_Top","")

arcpy.AddFeatureClassToTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Parcels_Topology\\Parcels_Dissolved","")

arcpy.AddRuleToTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Must Not Overlap (Area)","Parcels_Topology\\Parcels_Dissolved","","","")

#Validates topology
arcpy.ValidateTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Full_Extent")
0 Kudos
BillBass
Deactivated User
Yes, you can, to a point. Here are some sample scripts we use in a Python batch program. However, I have yet to find a method to extract the value that are displayed in the Generate Summary after the topology has been validated, or repair them in some automated fashion.

import arcpy

Scratch_Workspace = "G:\\CE\\Forecast\\Parcels_2008_2010\\Parcels_Scratch.gdb"
arcpy.env.workspace= Scratch_Workspace
arcpy.env.overwriteOutput= "True"

#Creates Feature Dataset and loads dataset into feature dataset
arcpy.CreateFeatureDataset_management(Scratch_Workspace,"Parcels_Topology","Parcels_Overlay_WD_Dissolved")

arcpy.Select_analysis("Parcels_Overlay_WD_Dissolved","Parcels_Topology\\Parcels_Dissolved","")

#Creates topology and adds loaded dataset to topology and assigns rule
arcpy.CreateTopology_management("Parcels_Topology","Parcels_Dissolved_Top","")

arcpy.AddFeatureClassToTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Parcels_Topology\\Parcels_Dissolved","")

arcpy.AddRuleToTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Must Not Overlap (Area)","Parcels_Topology\\Parcels_Dissolved","","","")

#Validates topology
arcpy.ValidateTopology_management("Parcels_Topology\\Parcels_Dissolved_Top","Full_Extent")
0 Kudos
JesseSheridan
New Contributor
Anybody have any luck Generating Summary for Topology Errors in an automated way?
0 Kudos