Hi,
I’m writing a python script to run some network analyst processes. The analysis process runs fine in terms of creating a route layer, adding all the relevant points and restrictions and solving the NA scenario. I have inspected the results by saving out a layer file of the results (using the Save to Layer File tool) and its all in order. This layer file links back to the ‘Memory Feature Class’.
The one issue I’m trying to overcome is how I then save the results as a standard feature class in a geodatabase. I’ve tried several different tools (copy features, features to line etc.), but they are all looking for a feature layer or feature class as the input.
Can someone tell me how I can save from a memory feature class to a standard feature class in python?
Thanks
Greg
Solved! Go to Solution.
Check out Code Sample #4 in the Make Route Layer tool reference in the doc.
Make Route Layer—ArcGIS Pro | ArcGIS for Desktop
# Get the output Routes sublayer and save it to a feature class RoutesSubLayer = arcpy.mapping.ListLayers(outNALayer, routesLayerName)[0] arcpy.management.CopyFeatures(RoutesSubLayer, outRoutesFC)
Are you saying that Copy Features doesn't work for you?
As far as I am concerned a feature class in the "in_memory" workspace is still a feature class. Should copy out the disk easily.
Check out Code Sample #4 in the Make Route Layer tool reference in the doc.
Make Route Layer—ArcGIS Pro | ArcGIS for Desktop
# Get the output Routes sublayer and save it to a feature class RoutesSubLayer = arcpy.mapping.ListLayers(outNALayer, routesLayerName)[0] arcpy.management.CopyFeatures(RoutesSubLayer, outRoutesFC)
It's been a while since I actually ran this, but should work just fine: (updated with corrections)
wsIN = "in_memory" wsOUT = r"H:\Documents\ArcGIS\MyFileGDB.gdb" arcpy.env.workspace = wsIN inFCS = arcpy.ListFeatureClasses() for inFC in inFCS: desc = arcpy.Describe(inFC) arcpy.CopyFeatures_management(inFC, wsOUT + "\\" + desc.name)
Thanks Melinda, Neil and James for your reply's.
From the sample code for the 'MakeRouteLayer' tool I managed to get it working. This code sample also has the details of how to setup the object that references the 'Routes' in the NA Route Layer.
thanks
Greg