Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Python Trace Geometric Network

$
0
0
Not sure why they post in the Desktop/Online help that this can be run via a standalone python script because the output is a group layer which isn't a data type that can be written out by python. The only way I've been able to get this to run successfully is to use this in the Python Window in an ArcMap Session using the network data you want to trace. If someone else out there has been able to use this successfully via a standalone script, please let me know the steps involved because I'd very much appreciate it.

Here's what I have so far. Definitely not the end product, but the only way I can work it so far:

Code:

sdnNet = r'C:\SDNTest\SDN.gdb\SDN\SDN_Net'
cbs = r'C:\SDNTest\SDN.gdb\SDN\CatchBasin'
oid = 1
rows = arcpy.SearchCursor(cbs)
for row in rows:
    newNet = 'SDN_Net'+str(oid)
    flags = 'flags'+str(oid)
    exp = '"OBJECTID" = '+str(oid)
    arcpy.MakeFeatureLayer_management(cbs,flags,exp)
    arcpy.gp.TraceGeometricNetwork(sdnNet, newNet, flags, "TRACE_DOWNSTREAM")
    oid += 1

Now that this is automated, I'm going to total the flow times along the paths that I calculated from another script and add them in to the corresponding flag in the actual network. Eventually I would like to turn this into a geoprocessing task on a public side arcgis server that users can perform this on the fly by selecting the flag of their choice, but for now I'm going to calc them all in myself.

Viewing all articles
Browse latest Browse all 2485

Trending Articles