Create layers from a list of symbology

Discussion created by maashorst on Feb 1, 2011
Oke so here is the thing:

We have a list of different birds and their location on a small map. Now we want to create a pdf for each bird and its locations.

We thought something like this:

import arcpy
from arcpy import env

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

# Set workspace
env.workspace = "D:/Documenten/04 Vogelwacht/Inventarisaties/Maashorst 2010"

# Set local variables
in_layer = "Maashorst.lyr"
out_layer = "studyquadsLyr.lyr"

#MakeFeatureLayer variables
in_features = "Maashorst10.shp"
out_layer0 = "studyquadsLyr"

# Soort is the column name and Appelvink is one of the species from that list
where_clause = "/\Soort/\ = 'Bonte vliegenvanger'"
workspace = "D:/Documenten/04 Vogelwacht/OUTPUT"

    # Execute MakeFeatureLayer
    arcpy.MakeFeatureLayer_management(in_layer, out_layer0)
    # with this line it goes wrong, we want to create a new layer based upon the where_clause

    # Execute SaveToLayerFile
    arcpy.SaveToLayerFile_management(in_layer, out_layer, "ABSOLUTE")
    print arcpy.GetMessages()

The error msg we get is:

Executing: SelectLayerByAttribute "D:/Documenten/04 Vogelwacht/Inventarisaties/Maashorst 2010\Maashorst.lyr" NEW_SELECTION "Soort = 'Bonte vliegenvanger'"
Start Time: Tue Feb 01 17:34:44 2011
Failed to execute. Parameters are not valid.
ERROR 000825: The value is not a layer or table view
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Mosaic Layer.
Failed to execute (SelectLayerByAttribute).
Failed at Tue Feb 01 17:34:44 2011 (Elapsed Time: 0.00 seconds)

When we run this in the program it self, the select method we get this line of code:

# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "Maashorst"
arcpy.SelectLayerByAttribute_management("Maashorst","NEW_SELECTION","/\Soort/\ = 'Bonte vliegenvanger'")

Anyone has any ideas? :)

The save to pdf will be a next chapter...