1

I want to extract specific values of raster layer. Use codes as follows:

attExtract=arcpy.sa.ExtractByAttributes(outraster,'VALUE==8 | \
                                            VALUE==9 | VALUE==10 | VALUE==16')

system hint the SQL is invalid:

ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
Failed to execute (ExtractByAttributes).

How to write the operation bool code?

3

Try this:

attExtract=arcpy.sa.ExtractByAttributes(outraster,'VALUE IN (8, 9, 10, 16)')
-1

I try "VALUE>=8 AND VALUE<=10 OR VALUE=16". It's OK! equal operator is =, not ==. Reference the SQL site

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.