I have a script I am using to save out layers automatically and would like some help with understanding where my files are being saved out to.
In my current code, the file that I am processing is being picked up in the arcpy.env.workspace.
But the layers that I am saving out are being saved in the same place. How do change where the files are being saved ?
import arcpy
from arcpy import env
#Variables which need to pick for this are the attribute that you are going to filter the layers on
# This is where the file is being picked up from
arcpy.env.workspace = "U:\\Script\\layers_Files\\"
# The file to be processed
Source_File = "feilds_template.shp"
Company_Bulk_Company_List = [row[0] for row in arcpy.da.SearchCursor (Source_File,"HC_TYPE")]
UniqueCompany = set(Company_Bulk_Company_List)
print UniqueCompany
# Getting the list out
for company_query in UniqueCompany:
#env.workspace = "S:\\AppsData\\GIS\\PROJECT\\COMPANIES\\SHAPEFILES\\"
out_layer0 = str(company_query)+"lyr"
in_layer = out_layer0
out_layer = in_layer +"lyr"
#MakeFeatureLayer variables
in_features = "IHS_FEILDS_AREAS.shp"
where_clause = '"HC_TYPE" = ' + "'" + company_query + "'"
print where_clause
workspace = " U:\\Script\\layers_Files\\"
try:
# Execute MakeFeatureLayer
arcpy.MakeFeatureLayer_management(in_features, out_layer0, where_clause, workspace)
# Execute SaveToLayerFile
arcpy.SaveToLayerFile_management(in_layer, out_layer, "ABSOLUTE")
except:
print arcpy.GetMessages()
workspace = " U:\\Script\\layers_Files\\"
, before yourtry
statement. I don't use Arc but your first algorithm "Execute MakeFeatureLayer" looks like it's outputting the results in theworkspace
location. This is just a guess =)