AnsweredAssumed Answered

Problems saving ODLines layer to disk

Question asked by RRG03CS on Jun 11, 2020
Latest reply on Jun 12, 2020 by RRG03CS

If have developed a python script that iterates through a list of 30 countries. For each country, I want to generate an OD matrix between origins and destinations. The script sucessfully sets up the MakeODCostMatrixLayer, adds the origins and destinations and solves the matrix. From the resulting matrix layers, I only want to save the ODLines layer to disk for further processing. My code is as follows (only those lines where the error occurs):

 

...

arcpy.na.Solve(outNALayer, "SKIP", "TERMINATE", "")  #until here the script successfully runs, and I can inspect the results in ArcCatalog

print ("... SAVING MATRIX TO LYR FILE ")
lyrsFile = arcpy.mp.LayerFile(outNALayer)
subLayers = dict((lyr.datasetName, lyr) for lyr in lyrsFile.listLayers())
LinesSubLayer = subLayers["ODLines"]
arcpy.SaveToLayerFile_management(LinesSubLayer, OD_MatrixLine_lyr, "", "CURRENT")
arcpy.CopyFeatures_management(OD_MatrixLine_lyr, outMatrix)

...

 

The script crashes after the print statement with the following error message:

<MappingLayerObject object at 0x000002A084AFEE88>

 

I am using ArcGIS Pro 2.5.1 and Python 3.6.9

 

Any ideas what happens? Maybe there is a simpler approach to save the ODLines layer to disk?

Any help is highly appreciated!

 

Carsten

Outcomes