Available with Standard or Advanced license.
The primary method for creating a new topology in ArcGIS Pro involves the use of geoprocessing tools. Once you know how to create a topology, you can automate this work using a suite of geoprocessing tools.
Create a topology using geoprocessing
ArcToolbox contains a series of geoprocessing tools for topology. The Topology toolset is located in the Data Management toolbox.
These tools can be used to build scripts for creating and modifying geodatabase topologies. Scripts can be useful for automating a series of tasks and for building repeatable workflows.
The process to create a topology using the Create Topology tool is as follows:
- Create a topology using the Create Topology tool.
- Choose the feature classes that will participate in the topology. Add these feature classes to the topology using the Add Feature Class To Topology geoprocessing tool.
Run this tool multiple times until you've added all of the feature classes that you want to participate in the topology.
- Now that you've created the topology and added some feature classes to it, you can add a series of rules using the Add Rule To Topology geoprocessing tool. Topology rules help you structure the spatial relationships between features and to control and validate how features share geometry.
You may also need to run this tool multiple times until you've added all of the desired topology rules to the topology.
- You now have a new topology in your feature dataset with participating feature classes and topology rules. If you have data in your feature classes, you can use the Validate Topology geoprocessing tool to validate your topology.
The following is a sample stand-alone Python script that you can use to create a topology and add multiple feature classes and rules to the topology:
This stand-alone Python script creates a topology, adds multiple feature classes and rules, and validates the topology.
import arcpy import os # Input variables input_dataset = r"C:\MyProjects\MyProject.gdb\fds" topo_name = "Topology" cluster_tol = 0.001 input_fc = r"C:\MyProjects\MyProject.gdb\fds\fc1 1 1;C:\MyProjects\MyProject.gdb\fds\fc2 1 1" rules = r"'Must Not Overlap (Area)' C:\MyProjects\MyProject.gdb\fds\fc1 # C:\MyProjects\MyProject.gdb\fds\fc1 #;'Must Be Covered By Feature Class Of (Area-Area)' C:\MyProjects\MyProject.gdb\fds\fc1 # C:\MyProjects\MyProject.gdb\fds\fc2 #" validate = "true" # Create the topology out_topo = arcpy.CreateTopology_management(input_dataset, topo_name, cluster_tol) print("Created topology.") # Loop through the list of feature classes and add them to the topology input_fcL = input_fc.split(";") for fc in input_fcL: param = fc.rsplit(" ", 2) in_fc = param xy_rank = param z_rank = param arcpy.AddFeatureClassToTopology_management(out_topo, in_fc, xy_rank, z_rank) print(arcpy.GetMessages()) # Loop through the list of rules and add rules to the topology rulesL = rules.split(";") for rule in rulesL: r = rule.rsplit(" ", 4) rule_type = r.replace("'","") in_fc1 = r subtype1 = r in_fc2 = r subtype2 = r arcpy.AddRuleToTopology_management(out_topo, rule_type, in_fc1, subtype1, in_fc2, subtype2) print(arcpy.GetMessages()) # Validate the topology if validate == "true": try: arcpy.ValidateTopology_management(out_topo) except: print(arcpy.GetMessages()) print("Finished.")