I would like to use Trace with result_types=['NETWORK_LAYERS']. I am unable to drill the layers in out_network_layer.
Here is an example of an attempt:
out_netk_layer = "out_net_lay"
stream_layer_name = 'Stream'
res = arcpy.tn.Trace(in_trace_network=t_network,
trace_type="SHORTEST_PATH",
starting_points=starting_points,
shortest_path_network_attribute_name="Shape length",
validate_consistency="VALIDATE_CONSISTENCY",
result_types=['NETWORK_LAYERS'],
out_network_layer=out_netk_layer)
if res:
total_length = 0
feature_class_path = '{}\\{}'.format(out_netk_layer, stream_layer_name)
with arcpy.da.SearchCursor(feature_class_path, ["SHAPE@"]) as cursor:
for row in cursor:
shape = row[0]
if shape.isSelected:
total_length += shape.length
arcpy.AddMessage("Total length : {} meters".format(total_length))
else:
arcpy.AddWarning("no trace result")
arcgisscripting.ExecuteError: Execution failed. The parameters are not valid.
ERROR 000732: Input Entities: Dataset out_net_lay/stream does not exist or is not supported
Where can I find a code example? What anomaly do you see here? Thanks for everything
I'm encountering the same issue. I'm expecting the trace to return a Group Layer object that could then be manipulated in the same way that the old Geometric Network trace results could be processed. It appears the new trace only returns a string when the result type = 'NETWORK_LAYERS'.
trace_result = arcpy.tn.Trace(network, 'CONNECTED', start_points, lyr_valve, include_barriers='INCLUDE_BARRIERS', validate_consistency='VALIDATE_CONSISTENCY', result_types='NETWORK_LAYERS', out_network_layer='TRACE1')
print(trace_result)
> Trace_Results_Aggregated_Points
It's frustrating because the script works as intended within ArcGIS Pro but doesn't as a stand-alone. I suspect that the Network Layer result type is only valid within ArcGIS Pro. The wording in the documentation should be made more clear if this is the case.
Dan_Joyce_OE_0-1702970343645.png
At the moment, this isn't a useful option for me as the stand-alone script gets published as a GP service so that it can be called from a web app.