In the past, I was creating an automated workflow to set up a utility network and then publish it to an enterprise portal. While coding, I discovered that it’s not possible to add a utility network to a map in ArcGIS Pro via the Python API—it always results in a runtime error.
Additionally, the same issue occurs in the portal web environment: It’s not possible to add a utility network feature layer from the portal into a web map using the ArcGIS Python API. The issue seems to lie with the layer of type "Utility Network Layer"; the error message indicates that it doesn’t have a renderer attached yet.
After contacting support, I was informed that this functionality hasn’t been developed yet. Since this feature would be quite important for working with utility networks in an enterprise environment, it would be very helpful if this functionality could be introduced in the future.
Best regards!
We are implementing a similar workflow where we make a full copy of our Water Utility Network in a different Postgres database and schema to publish a service specifically for running trace functionality. Each time we drop and recreate the replica of the Utility Network, we must republish the service manually (due to the internal naming of a number of UN objects - UN_1234_DirtyAreas for example).
We are able to add the Network layer to an APRX using arcpy (code included below), but the issue we are hitting is at the publishing stage when calling
arcpy.UploadServiceDefinition_server
Have you (or anyone reading this) been able to automate the publishing of a Utility Network service?
In case it helps, here is the basic code we are using to add the Network object to an APRX. And for reference, we are running ArcGIS Pro 3.3.1 and Python 3.9.
import arcpy
mapname = "TraceReplica"
map_document_fullpath = rf"D:\repos\UtilityNetworkTrace\{mapname}.aprx"
aprx = arcpy.mp.ArcGISProject(map_document_fullpath)
m = aprx.listMaps(mapname)[0]
d = r"***path_to_sde_connection_file***\untrace.tracereplica.UtilityNetwork\untrace.tracereplica.Network"
m.addDataFromPath(d)
aprx.save()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.