1

I am using PyScripter and ArcMap

import arcpy

# set up workspace and input feature class
arcpy.env.workspace = r"H:\Data_Processing\Work\PL07\Mygdb.gdb"
fc = "County"

# create a topology for the feature class
topology = arcpy.CreateTopology_management(arcpy.env.workspace, "topology")
arcpy.AddFeatureClassToTopology_management(topology, fc, 1, 1)

# add topology rules to the topology
arcpy.AddRuleToTopology_management(topology, "Must Not Overlap (Area)", fc)
arcpy.AddRuleToTopology_management(topology, "Must Not Have Gaps (Area)", fc)
arcpy.AddRuleToTopology_management(topology, "Must Not Self-Intersect (Line)", fc)

# validate the topology to find errors
error_table = arcpy.ValidateTopology_management(topology)

# loop through the error table to print out error messages
with arcpy.da.SearchCursor(error_table, ["RuleDescription", "Description"]) as cursor:
    for row in cursor:
        print("Error: {} - {}".format(row[0], row[1]))

"
I get the error below (how do I fix it?)

Traceback (most recent call last):
  File "<module3>", line 32, in <module>
  File "E:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\management.py", line 18933, in CreateTopology
    raise e
ExecuteError: ERROR 000271: Cannot open the input datasets
Failed to execute (CreateTopology).
0

1 Answer 1

3

You are attempting to create the topology in the root level of the GDB. Topology has to be created in a feature dataset. Try the following:

# set up workspace and input feature class
arcpy.env.workspace = r"H:\Data_Processing\Work\PL07\Mygdb.gdb\someDataset"
fc = "County"

# create a topology for the feature class
topology = arcpy.CreateTopology_management(arcpy.env.workspace, "topology")[0]
5
  • Thank you, Mark, I still get the same error message. Traceback (most recent call last): File "H:\WIP\32_WIP_MS\Ref\Py\module2.py", line 19, in <module> topology = arcpy.CreateTopology_management(arcpy.env.workspace, "topology") File "E:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\management.py", line 18933, in CreateTopology raise e ExecuteError: ERROR 000271: Cannot open the input datasets Failed to execute (CreateTopology). Commented Apr 13, 2023 at 11:38
  • Can anyone help with the above. Commented Apr 24, 2023 at 15:12
  • What troubleshooting have you done to try and resolve your issue? You haven't update the script to show the feature dataset that you are using. Have you got the correct path to the dataset? Have you got an appropriate license available? Add a print(arcpy.ProductInfo()) at the top of the script to check you are not at basic. Have you made sure the the GDB is not locked out by another process? Does the topology create successfully using the Create Topology tool? Commented Apr 25, 2023 at 22:20
  • Thanks Mark for your response. I have tried different script options (as best as I can). No feature dataset generated. I have a GDB with a couple of feature classes in it. Yes, I have the correct path to the dataset. Yes, I have an appropriate license. Done - print(arcpy.ProductInfo()) GDB is not locked (tried a few times) Topology does not create. Commented May 9, 2023 at 10:59
  • Your statement "No feature dataset generated" is the key. I suggest you read desktop.arcgis.com/en/arcmap/latest/manage-data/topologies/… At step 6 it mentioned you must create a feature dataset first and copy the features you are going to create the topology for into the feature dataset before you can create a topology. Commented May 23, 2023 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.