route.solve() - RouteEdges does not give expected output

2391
9
12-14-2022 01:43 AM
ManishGohil
Occasional Contributor

RouteEdges do gives multiple entries for single SourceOID when solving route through route.solve().
Reference URL - https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/route.htm

Actual Output:

SourceOID FromPosition ToPosition
2876011600.210675
287601160.2106750.672682
287601160.6726821

 

Expected Output:

SourceOID FromPositionToPosition
2876011601

 

Please find attached sample route solve result "io.gdb.zip" for clear understanding and analysis.

0 Kudos
9 Replies
JaySandhu
Esri Regular Contributor

The source features when made into a network dataset may get split into many features based on the connectivity policy to deal with other crossing roads. The route solve will return a single line for the route and then the Copy Traversed Source Features tool can return back the underlying edges. And in this case it will return back all the pieces of an original feature with the from/to positions. That is the expected result as that is what is contained in the network dataset.

You could run the Dissolve tool on the RouteEdges, dissolving on the SourceOID to return back one edge per SourceOID. You will probably want to uncheck the Return Multipart and check on the Unsplit Lines options when you use this tool.

Jay Sandhu

0 Kudos
ManishGohil
Occasional Contributor

Thank you for your quick response. We can't use the Dissolve tool as we are using the SMP network dataset and I am not seeing any property in the https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/route.htm

0 Kudos
JaySandhu
Esri Regular Contributor

You run the dissolve tool on the output of the solve. Not on the input network dataset.

Where do you see the multiple SourceOIDs that make up the route? It is in the routeedges feature class in the data you uploaded. So that is what you dissolve.

Jay Sandhu

0 Kudos
ManishGohil
Occasional Contributor

The problem is I don't want to dissolve multiple segments/edges into one single segment/edge. Here, the problem we are facing is that a single edge/segment from the network dataset (for example 28760116 is a segment) is split into multiple segments/edges (3 entries for a 28760116 segment). 

 

We will try the dissolve tool and update you with the result.

0 Kudos
JaySandhu
Esri Regular Contributor

I guess I do not understand your issue.

Where are you seeing the split multiple segments. How are they being generated. What do you need to accomplish? Perhaps some more details may help. 

Jay Sandhu

0 Kudos
ManishGohil
Occasional Contributor

Hi @JaySandhu  - Thank you for your quick response. I am attaching an Excel file to make it more clear.

One worksheet has 3 parts.

1) Tool output

2) Run the dissolve tool on the tool output

3) Expected output

 

If you see the difference between 1 & 3, tool output(1) is returning unnecessarily breaking the single edge into multiple edges though the vehicle is going to travel the whole edge. 

We need these edges to implement some business functions and it's having performance issues so we are looking for an OOB solution to get the expected out (3).

 

ManishGohil_0-1671124289565.png

 

0 Kudos
JaySandhu
Esri Regular Contributor

When you use the Dissolve Tool, rather than using Min/Max statistics, try First and Last as follows:

JaySandhu_0-1671132471907.png

Perhaps this will give you the expected results.

Jay Sandhu

ManishGohil
Occasional Contributor

Hello @JaySandhu ,

We also discussed this with ESR and the split route segment was due to network junctions.

The solution you provided works but there are two requirements that is missing with this approach,

1)Maintain sequence of street segments and

2)it does not does not dissolve segment if,  same segment come more then once e.g. in case of return route.

So, the only way is to build some custom code to merge continuous route segments. 

Thank you for your help

 

 

0 Kudos
JaySandhu
Esri Regular Contributor

When you say return route, do you mean that you have multiple routes? That is, RouteID 1 has a segment that also occurs in RouteID 2?

If that is the case, then in the Dissolve tool, Add the RouteID as the second dissolve field. Now, RouteID 1 and 2 will dissolve separately.

JaySandhu_0-1671732458426.png

Jay Sandhu

0 Kudos