AnsweredAssumed Answered

Export Route Layer from Closest Facility using Python

Question asked by priyanka_mehta on Apr 21, 2015
Latest reply on Apr 21, 2015 by priyanka_mehta

Hi,

How should I export route layer that is a part of closest facility layer.

It works with the model builder if I use "Select Data" followed by Copy Features but if I even save that model builder as python script , it does not work.

 

This is the exported python script from model builder
# Local variables:
Closest_NationalParks_Facility = "Closest_NationalParks_Facility"
Routes__2_ = "C:\\Projects\\RAFT\\Closest_NationalParks_Punggol\\Routes"
CFRoutes_CopyFeatures = "C:\\Users\\mehtap\\Documents\\ArcGIS\\Default.gdb\\CFRoutes_CopyFeatures"
# Process: Select Data
arcpy.SelectData_management(Closest_NationalParks_Facility, "Routes")
# Process: Copy Features
arcpy.CopyFeatures_management(Routes__2_, CFRoutes_CopyFeatures, "", "0", "0", "0")

 

It does not recognize Closest_NationalParks_Facility as a dataset at the first place and gives this error

"ERROR 000732: Input Data Element: Dataset Closest_NationalParks_Facility does not exist or is not supported"

I tried modifying it by adding ".lyr" to the input. It can do select data with that but still not copy features.

# Local variables:
Closest_NationalParks_Facility = "C:\\Projects\\RAFT\\Closest_NationalParks_Facility.lyr"
CFRoutes_CopyFeatures = "C:\\Users\\mehtap\\Documents\\ArcGIS\\Default.gdb\\CFRoutes_CopyFeatures2"
# Process: Select Data
sel = arcpy.SelectData_management(Closest_NationalParks_Facility, "Routes")
# Process: Copy Features
arcpy.CopyFeatures_management(sel, CFRoutes_CopyFeatures, "", "0", "0", "0")

 

"sel" returns :

>>> sel
<Result 'C:\\Projects\\RAFT\\Closest_NationalParks_Facility.lyr\\Closest_NationalParks_Facility\\Routes'>

 

I cannot understand how to make "Routes" sub layer be recognized or anyhow export Route layer to geodatabase.

 

Regards,

Priyanka Mehta

Outcomes