SQL and output syntax for Extract by Attributes

334
1
04-03-2012 10:13 AM
AnneRiddle
New Contributor
Hi all,

I have a couple of questions related to the syntax for Extract by Attributes, related to the code block below (part of a larger script):

for raster in arcpy.ListRasters: 
    outpoint = workspace + raster + "af"
    sqlclause = "VALUE" = 6 OR "VALUE" = 8
    extract = arcpy.ExtractbyAttributes (raster, sqlclause)
    extract.save (outpoint)


My understanding is that extract.save is the only way to save the output of Extract by Attributes. Do I need to create a full file pathname for this, or does it automatically save in the current workspace? (i.e., can I drop "workspace" from outpoint or is it understood to save within the current workspace?). Sorry if this is an obvious question, but I can't seem to find any documentation on this syntax.

Also, I'm copying the syntax from the online example for the SQL query, but it looks totally incorrect; does it need to be enclosed in square brackets?

Thanks.
Tags (2)
0 Kudos
1 Reply
DarrenWiens2
MVP Honored Contributor
As far as the SQL is concerned, look at the examples in the 'where clause' section on this page (basically, enclose it in quotes in your favourite manner).

I don't know about the workspace question, but just try it one way and if it doesn't work, try it the other (takes less time than waiting for an answer).
0 Kudos