Select to view content in your preferred language

nax library saveAsLayerFile creates layer files (.lyr) with no labelling

919
4
09-05-2023 03:27 AM
SOTIRIOSTRIANTOS
Regular Contributor

When trying to save as layer file (.lyr) an arcpy.nax.VehicleRoutingProblemResult or an arcpy.nax.RouteResult object  the symbols are black without labels.

SOTIRIOSTRIANTOS_0-1693909615427.png

 

 

SOTIRIOSTRIANTOS_1-1693909615544.png

 

This doesn't occur when saving in lpkx format.

SOTIRIOSTRIANTOS_2-1693909615177.png

0 Kudos
4 Replies
MelindaMorang
Esri Regular Contributor

This is more or less expected.  The .lyr format is an old ArcMap layer format, and Pro has to do a bunch of modifications and simplifications to the Pro-style network analysis layer to back-port it into the ArcMap-style layers.  Various things are not compatible and will get lost in translation.

0 Kudos
SOTIRIOSTRIANTOS
Regular Contributor

Thank you for your reply. I understand that there are compatibility issues. We are trying to keep logs, and it takes 10 seconds to save in LPKX, whereas it only takes 1.5 seconds in LYR. Of course, we have the option to ommit keeping logs, but I felt it necessary to mention this.

Another point worth mentioning is that in ArcGIS Pro, there is no option to define the Datasource (network dataset)

SOTIRIOSTRIANTOS_0-1693922018998.png

LYR files are saved using the following code: arcpy.management.SaveToLayerFile(outNALayer, outLayerFile_Ldisk, "RELATIVE").

With ArcGIS Desktop, we haven't encountered any issues. It prompts us to define the Datasource (network dataset) and loads the layer. If possible, you could try this in ArcMap.

SOTIRIOSTRIANTOS_1-1693922041034.png

 

As a company, we are very satisfied with the Network Analyst extension. However, there is a feeling that more can be done to facilitate the transition from ArcMap to ArcGIS Pro.

0 Kudos
MelindaMorang
Esri Regular Contributor

Yes, network analysis layers were substantially changed when we moved from ArcMap to Pro, and the problems you're encountering are related to those differences.  In ArcMap, the data for the sublayers was held in memory.  The only data source for ArcMap-style layers was the network dataset, and you could have a relative or absolute path to that dataset.  In Pro, the sublayers reference feature classes on disk, so network analysis layers effectively have multiple data sources (the network dataset and the sublayer data).

When you save your arcpy.nax solver object results to a .lyr file, it converts the sublayer data to the old-style in-memory feature classes.  You're correct that there's no option to set a relative or absolute path to the network dataset.  I believe it should work as long as the path to the network dataset is maintained.  If you moved the .lyr files to a different folder, then the relative path to the network dataset path is probably broken.  I can investigate whether we can fix this, but we are limited as to what we can do with .lyr files at this point.  We don't really recommend using these because various settings (like travel modes) aren't fully supported in .lyr files.

The .lpkx files are slower to create because it must write the sublayer data to feature classes on disk and go through the packaging process, which can be slow.  The .lpkx output will definitely be more accurate and functional than the old .lyr files because they were designed for Pro compatibility.

Honestly, both of these outputs are intended primarily for one-off debugging purposes (we use them a lot for debugging problems with network analysis services) where you need to investigate the analysis in a map and determine what went wrong.  We don't really recommend that they be a part of regular customer workflows.  If you tell me more about what type of logs you want to keep, I can try to suggest an alternate option that might work better.  For example, maybe you can just write out all the settings to a json file, and if you needed to reload and re-run the analysis, you could just ingest the json in a script.

0 Kudos
MelindaMorang
Esri Regular Contributor

If the main thing causing you a problem here is the labeling and symbology, you might be able to resolve the problem by saving a layer file with the symbology you want and calling the Apply Symbology From Layer tool to apply this symbology to the .lyr files saved by your tool.

0 Kudos