after 2.6.2 network analyst renaming items

685
3
Jump to solution
10-07-2020 12:10 PM
WilliamBlake1
New Contributor II

It seems after 2.6.2 pro update last week that all my network analyst layers and feature classes within have been renamed with some six random letters added at the end of the name.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MelindaMorang
Esri Regular Contributor

DanPatterson1's link is correct.  I will repost the response here (with better formatting) in case other users have this question.

This behavior is as designed. The feature datasets and feature classes for network analysis layers use automatically-generated unique names. In previous releases, this was done using a numbering scheme, but this was changed later on to a string of alphanumeric characters.

 

When writing scripts, you should not try to access the network analysis layer’s sublayers directly by their data paths, as this is not a supported workflow and the naming convention is not static or guaranteed. Instead, here are two ways to directly access the results of a network analysis:

Method 1

Use this method if you have a layer-based workflow in a python script. Retrieve the output sublayer’s layer object and grab the data source from this or just use the layer object itself as input into further tools. Here is an example for a Closest Facility layer. You can retrieve the Routes sublayer object from the parent Closest Facility layer object like this:

routes_sublayer = layer_object.listLayers("Routes"])[0]

You can then do routes_sublayer.dataSource if you want to see the actual catalog path to the data source. You can use that catalog path or the routes_sublayer object itself as input into other geoprocessing tools.

Note that with the release of ArcGIS Pro 2.7, you will be able to use the new arcpy.na.GetNASublayer() function to retrieve the sublayer of a parent layer instead of the listLayers() method.

To see a full workflow example similar to this, see the “MakeODCostMatrixAnalysisLayer example 4” code sample here: https://pro.arcgis.com/en/pro-app/tool-reference/network-analyst/make-od-cost-matrix-analysis-layer.... (This uses OD Cost Matrix instead of Closest Facility, but it’s the same idea.)

Method 2

This is an entirely different way of solving a network analysis problem in python, one that does not involve layers at all. In ArcGIS Pro, we introduced a new python module, arcpy.nax, that provides a new python interface for doing network analysis. The new interface is more pythonic and easier to use in many ways. You can learn the basics of how it works here: https://pro.arcgis.com/en/pro-app/arcpy/network-analyst/performing-network-analysis.htm

To summarize, you create a network analysis object for the solver you want, load the desired inputs, solve, and then retrieve the results in one of several ways. You can use the export() method on the solver result object to save the outputs to a feature class. You can also retrieve the outputs using a cursor, so it’s possible to retrieve only the fields you care about and write them directly into another table that already has your desired schema.

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor
WilliamBlake1
New Contributor II

thanks for the fast answer, this breaks lots of our code.

0 Kudos
MelindaMorang
Esri Regular Contributor

DanPatterson1's link is correct.  I will repost the response here (with better formatting) in case other users have this question.

This behavior is as designed. The feature datasets and feature classes for network analysis layers use automatically-generated unique names. In previous releases, this was done using a numbering scheme, but this was changed later on to a string of alphanumeric characters.

 

When writing scripts, you should not try to access the network analysis layer’s sublayers directly by their data paths, as this is not a supported workflow and the naming convention is not static or guaranteed. Instead, here are two ways to directly access the results of a network analysis:

Method 1

Use this method if you have a layer-based workflow in a python script. Retrieve the output sublayer’s layer object and grab the data source from this or just use the layer object itself as input into further tools. Here is an example for a Closest Facility layer. You can retrieve the Routes sublayer object from the parent Closest Facility layer object like this:

routes_sublayer = layer_object.listLayers("Routes"])[0]

You can then do routes_sublayer.dataSource if you want to see the actual catalog path to the data source. You can use that catalog path or the routes_sublayer object itself as input into other geoprocessing tools.

Note that with the release of ArcGIS Pro 2.7, you will be able to use the new arcpy.na.GetNASublayer() function to retrieve the sublayer of a parent layer instead of the listLayers() method.

To see a full workflow example similar to this, see the “MakeODCostMatrixAnalysisLayer example 4” code sample here: https://pro.arcgis.com/en/pro-app/tool-reference/network-analyst/make-od-cost-matrix-analysis-layer.... (This uses OD Cost Matrix instead of Closest Facility, but it’s the same idea.)

Method 2

This is an entirely different way of solving a network analysis problem in python, one that does not involve layers at all. In ArcGIS Pro, we introduced a new python module, arcpy.nax, that provides a new python interface for doing network analysis. The new interface is more pythonic and easier to use in many ways. You can learn the basics of how it works here: https://pro.arcgis.com/en/pro-app/arcpy/network-analyst/performing-network-analysis.htm

To summarize, you create a network analysis object for the solver you want, load the desired inputs, solve, and then retrieve the results in one of several ways. You can use the export() method on the solver result object to save the outputs to a feature class. You can also retrieve the outputs using a cursor, so it’s possible to retrieve only the fields you care about and write them directly into another table that already has your desired schema.

0 Kudos