Return features from Network Analyst Route solve

2100
14
Jump to solution
08-02-2021 06:54 AM
AndyWhitaker1
New Contributor III

Is it possible to have the Network Analyst return the features (route segments) on a route?  It seems we only get the merged geometry and directions.

1 Solution

Accepted Solutions
MaxZeng
Esri Contributor

@AndyWhitaker1Thank you for sharing how you are using the traversal result. After looking at your use case, the traversal result is indeed what you need to know those features that get traversed. Unfortunately NAServer service doesn't have the capability to return traversal result right now, so the only easy way to do it is using the geoprocessing service published via publish routing services utility (PRS). You could also create custom script that uses solver object as Melinda suggested and publish as geoprocessing service, but the geoprocessing service published via PRS are also written using solver object. The custom geoprocessing service created with solver object could be used to further extend what is not available in geoprocessing service published via PRS.

There are ways to make geoprocessing service faster though. Here is how:

Once you run the publish routing services utility, you will have a folder with these four services.

MaxZeng_1-1628018867296.jpeg

The NetworkAnalysis geoprocessing service (the first service in the screenshot), is published as asynchronous geoprocessing service by publish routing services utility. And it corresponds to GPServer asynchronous service. You could potentially go into the service parameters (by clicking the pencil next to the service) and change it to synchronous geoprocessing service. By doing this, instead of using submitJob on the geoprocessing service and query the job id for the job status, you will use execute on the geoprocessing service and wait for the job to finish. Here are some more information about executing sync geoprocessing service

MaxZeng_0-1628018840138.png

 

Make the service synchronous will make the service run faster.

View solution in original post

14 Replies
MelindaMorang
Esri Regular Contributor

Yes. You can use the Copy Traversed Source Features tool for this.

FabianoFerrazza3
New Contributor II

Hi Melinda.

It's ok from desktop, but how is it possible using the Network Analyst Service?

0 Kudos
MelindaMorang
Esri Regular Contributor

Unfortunately it is not possible to use that tool with a service.

0 Kudos
FabianoFerrazza3
New Contributor II

Ok, thank you.

Are there any method to get the traversed features in the "web scenario"?

I did did it by an ArcObjects soe, using the NALayer (.lyr file), but it's not compliant to the new Enterprise SDK.

Thank you again

0 Kudos
MelindaMorang
Esri Regular Contributor

Yes, depending on the service, you should be able to retrieve the traversed features by doing your workflow in python using the arcpy.nax solver objects. Here is some documentation: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/performing-network-analysis.htm

The Route solver object has RouteEdges, RouteJunctions, and RouteTurns output types, so you should just be able to retrieve those.

Route solver object: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/route.htm

Route solver result object: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/routeresult.htm

Route output data types: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/route-output-data-types.htm 

Ways to access output: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/accessing-analysis-outputs.htm

 

AndyWhitaker1
New Contributor III

Thanks @MelindaMorang!  I'll read through those documents to see if I am able to find an approach that will work.  I'll add another post here once I've come to a conclusion.

0 Kudos
FabianoFerrazza3
New Contributor II

So, Python is the only way to accomplish this, right?

Do you think will be ever added a rest parameter to obtain the traversed features directly by NAService?

Thank you again @MelindaMorang !

AndyWhitaker1
New Contributor III

I agree that ideally, this would be a REST parameter that could be set.

After reading through some of the docs, it seems that turning on some parameters on the network analyst service, such as returnRouteEdges might do the trick?  My knowledge of this side of things is limited, as I'm a developer working on a GIS project, and not a GIS professional.

I saw a property for the Network Analyst, routeShapeType, which sounds like setting to TrueShape might return the underlying features?  

https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/routeshapetype.htm

I saw a similar property to the routeShapeType in the ArcGIS for JavaScript API:

https://developers.arcgis.com/javascript/3/jsapi/routeparameters-amd.html#outputlines

0 Kudos
MelindaMorang
Esri Regular Contributor

@AndyWhitaker1 and @FabianoFerrazza3 are the two of you working on the same project? I'm not sure whether I'm having two separate conversations at once or if it's all the same thing. 😁

Regarding the python solver objects, you need to set returnRouteEdges to True and then retrieve the RouteEdges output type from the result. The routeShapeType property is unrelated. That controls the shape of the features in the Routes output. Regardless of your choice there, the "traversal result", which is the network edges that were traversed, will always be the same and can be retrieved through RouteEdges.

0 Kudos