Export features from Dirty Area layer using Python (ArcGIS pro 2.6)

777
7
03-07-2021 11:07 PM
geopamplona
New Contributor III

Hi,

I am trying export Dirty Areas from invalid Utility Network package using Python (ArcGIS Pro 2.6).

I using this script:
arcpy.conversion.FeatureClassToFeatureClass(r"Network Utility Network\Dirty Areas", r"C:\MyProject1.gdb", "output_fc")

But do not work in my script

 

0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

the error message you got?

and was that one line your script?  it probably can't find your r"Network Utility Network\Dirty Areas" because it probably doesn't know where it is, depending where you are running your script (eg separate IDE, python window, notebook)

Start with providing the error message, then the actual script and where you are running it from.


... sort of retired...
JonDeRose
Esri Contributor

Seconding Dan's suggestion.  The script is "correct" as written however, the issue is most likely access to the data.

0 Kudos
geopamplona
New Contributor III

Indeed, it is an error related to data access. This is the error:


Message=Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset Network Utility Network\Dirty Areas does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).

 

Code:

arcpy.env.workspace = 'C:\\un.gdb'

output_path='C:\\Results'
arcpy.conversion.FeatureClassToFeatureClass(r"Network Utility Network\Dirty Areas", output_path, "output_fc")

 

GDB and network:

geopamplona_0-1615451725577.png

 

 

 

0 Kudos
DanPatterson
MVP Esteemed Contributor
arcpy.env.workspace = r"C:\...path_to...\un.gdb"
 # Set local variables
inFeatures = "Network Utility Network\Dirty Areas" # never use spaces
outLocation = r"C:\... path_to...\Results"  # do you want it to a folder or gdb???
outFeatureClass = "output_fc"  # --- might want a descriptive name
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, 
                                            outFeatureClass)

perhaps....

Although I question gdb in the root of C:\ and your use of paths in the featureclass names is a good source of failure.  And finally, are you wanting to dump the results to a folder?  is it a shapefile? if so, it should end in *.shp

That was drawn from the sample help file code

Feature Class To Feature Class (Conversion)—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
geopamplona
New Contributor III

I don't care how to write the output file, using a gdb or a shp file. In the example it is enough to export a shp file.

It is possible that the use of spaces is giving problems; strange thing is that it does not match structure I have in the utility network package.
I have added the extension to the output file "output.shp" but it still gives the same error, it is a data access issue.

I have attached the network structure, and I have tried different combinations of the code indicating as input layer "UN\Network\Dirty Areas" or "UN\Dirty Areas" or "UN\Network Utility Network\Dirty Areas"; but it doesn't work.

I have attached the structure of the GDB in my previous post.

Thanks Dan !

 

0 Kudos
geopamplona
New Contributor III

Maybe what you are trying to say is that I should not use the "FeatureClassToFeatureClass" command to extract Dirty Areas from Network?

I have checked that this function is one used by Arcgis pro 2.6 when I do the same operation from the GUI.

0 Kudos
geopamplona
New Contributor III

Hi @JonDeRose

I have read many of your recent articles about UtilityNetwork, I think you are the most knowledgeable and experienced person on UtilityNetwork right now.
For months I am immersed in a migration process to UtilityNetwork, and all your articles are of great help to be updated on the improvements and new features that tool brings.
As you know topological errors and dirty areas are quite important to carry out migration, when source data does not always follow ESRI topological rules or connectivity rules may vary during a testing period or simply need to better communicate to client thousands of errors and dirty areas that need to be corrected before migrating to UN.

Because of this it becomes very important to be able to debug the dirty areas, to detect well which elements are involved and to correct error quickly. This is why I try to export the invalid areas to shp.

https://www.esri.com/arcgis-blog/products/utility-network/data-management/dirty-area-management-with...

Thanks !

 

 

0 Kudos