Extract Dirty Areas layer from Utility Network and get Topology Network properties using ArcPy.

685
3
Jump to solution
02-02-2022 04:06 AM
geopamplona
New Contributor III

Hello,

I am trying to extract the Dirty Areas layer from a Utility Network, but I have not succeeded.

I am trying using the command:

 

Input_Features="c:\...gdbUtilityNetwork\Network".
Output_Folder="c:\output.shp"
arcpy.conversion.FeatureClassToShapefile(Input_Features, Output_Folder)

 

 

As a result I get an error message saying that the input file is not supported.

geopamplona_0-1643802951309.png

https://pro.arcgis.com/es/pro-app/latest/tool-reference/conversion/feature-class-to-shapefile.htm

On the other hand, I try to get properties of topology network to know if there are dirty areas or not; for example the dirty area count.

 

geopamplona_0-1643802658400.png

 

I am using python 3.6 and ArcGIS Pro 2.6

Best regards!

0 Kudos
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor

Here is a little sample I put together that is working:

import arcpy
gdb = r'C:\temp\Communications_UtilityNetwork.gdb'
d = arcpy.Describe(rf'{gdb}\UtilityNetwork\Network')
da_path =fr"{gdb}\UN_{d.DSID}_DirtyAreas"
Output_Folder="C:\\results"
da_d = arcpy.Describe(da_path)
da_da = arcpy.da.Describe(da_path)
print(da_d.catalogPath)
print(da_da['catalogPath'])
print(da_path==da_d.catalogPath)
arcpy.Exists(da_path)
arcpy.GetCount_management(da_path)
arcpy.FeatureClassToFeatureClass_conversion(da_path,r'c:\temp\temp.gdb','DAExport')

View solution in original post

3 Replies
MikeMillerGIS
Esri Frequent Contributor

You can access the Dirty Areas from the Utility Network Composite layer in the map.  Use the Dirty Area sublayer in your GP tool, or open the properties and look at the source to get the path.  If you need to access it outside of pro, you will need to use that path from the sublayer.  The Dirty Area is always named like UN_<DSID>_DirtyAreas.  The DSID is the dataset ID of the utility network.  You can find the DSID of the UN in a number of ways, but I just usually look for the terminal attribute domain.  It will be in the format of UNName_DSID_TerminalNames.  The number in the middle is the DSID.

MikeMillerGIS_0-1643805927790.png

 

So in a GP tool, use a path like 

C:\temp\1_ElectricUtilityNetworkFoundation\Database\UNAdmin@PostgreSQL@Electric_2022_01_27.sde\UN_11_DirtyAreas

 

0 Kudos
geopamplona
New Contributor III

Hi @MikeMillerGIS 

 

Thank you for your answer, it is very useful !

I have detected the DSID and managed to access the DirtyAreas layer:

ad = arcpy.da.Describe(r'C:\un_water.gdb\UN\Network')
Input_Features=f"C:\\un_water.gdb\\UN\\Network\\UN_{ad['DSID']}_DirtyAreas"
Output_Folder="C:\\results"
desc_da=arcpy.da.Describe(Input_Features)

 

The object desc_dirty_areas has the description of the layer, so it exists. I can also get the full path to the same object with the "catalogPath" property:

arcpy.conversion.FeatureClassToShapefile(desc_da['catalogPath'], Output_Folder)

When I run this I get an error that the resource does not exist or is not supported.

I try to do an arcpy.GetCount on the dirty areas sublayer and get an error:

geopamplona_0-1643814694503.png

 

I have not found documentation on how to deal with sublayers in arcpy; maybe I am missing some intermediate step to use the layer??
note that I'm using a FGDB not a corporate database; can it influence?

Thanks!

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Here is a little sample I put together that is working:

import arcpy
gdb = r'C:\temp\Communications_UtilityNetwork.gdb'
d = arcpy.Describe(rf'{gdb}\UtilityNetwork\Network')
da_path =fr"{gdb}\UN_{d.DSID}_DirtyAreas"
Output_Folder="C:\\results"
da_d = arcpy.Describe(da_path)
da_da = arcpy.da.Describe(da_path)
print(da_d.catalogPath)
print(da_da['catalogPath'])
print(da_path==da_d.catalogPath)
arcpy.Exists(da_path)
arcpy.GetCount_management(da_path)
arcpy.FeatureClassToFeatureClass_conversion(da_path,r'c:\temp\temp.gdb','DAExport')