Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

What defines where the files will be saved?

$
0
0

Hi I have a script I am using to save out layers automatically

I have posted another question here

ArcGIS creating individual layers for unique attribute in a given feild. Limitations of Where Clause

I would also 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()

Viewing all articles
Browse latest Browse all 767

Trending Articles