1

I am using three cons with raster calculator to give four different results depending on the values within two rasters, aclip20151111 and sclip20151111. There are four results I want; RESULTA, RESULTB, RESULTC AND RESULTZ, RESULTZ being the result for when none of the three conditions are met. My code is below:

CON(((0 <= "aclip20151111" <= 45 | “aclip20151111” > 315)&(“sclip20151111” <
3)),RESULTA,CON(((45 < "aclip20151111" <= 135 | 225 < “aclip20151111” >= 315)
&(“sclip20151111” < 10)),RESULTB,CON(((135 <= "aclip20151111" <= 225)&(“sclip20151111” < 15)
),RESULTC,RESULTZ)))

I am getting the error "ERROR 000989 Python syntax error: Parsing error SyntaxError: invalid syntax (line 1)".

What is the error in my input to raster calculator? I am using raster calculator as a tool in Arcmap.

1 Answer 1

1

You have to use conjugated conditions using 'and' or 'or', I do not think you can just write a straight forward statements like a<raster<b

Try:

Con(((("aclip20151111" >= 0)& ("aclip20151111" <= 45))|((“aclip20151111” > 315)&(“sclip20151111” <3))), RESULTA, Con(((("aclip20151111">45) &("aclip20151111" <= 135)) | (((“aclip20151111” >225) & (“aclip20151111” >= 315)&(“sclip20151111” < 10)))),RESULTB,Con(((("aclip20151111" >=135) & ("aclip20151111" <= 225)) &(“sclip20151111” < 15)), RESULTC, RESULTZ)))

But make sure you check all the conditions, I might have gotten what you wanted to do wrong.

5
  • Many thanks reply, still getting the syntax error though sadly. Nov 11, 2015 at 17:46
  • yes there was one bracket missing, Con(((("aclip20151111" >= 0)& ("aclip20151111" <= 45))|((“aclip20151111” > 315)&(“sclip20151111” <3))), RESULTA, Con(((("aclip20151111">45) &("aclip20151111" <= 135)) | (((“aclip20151111” >225) & (“aclip20151111” >= 315)&(“sclip20151111” < 10)))),RESULTB,Con(((("aclip20151111" >=135) & ("aclip20151111" <= 225)) &(“sclip20151111” < 15)), RESULTC, RESULTZ))) try it now, use a notepad editor that higlights properly closed brackets easily, I use notepad++ it is great for catching errors
    – yanes
    Nov 11, 2015 at 17:52
  • I've updated the answer
    – yanes
    Nov 11, 2015 at 17:53
  • Unfortunately still getting the same error. I've checked in notepad++ and your answer does have the correct number of brackets so its something else. Nov 12, 2015 at 8:41
  • 1
    Looks like the issue may that I was pasting from word which puts in "smart quotes", I've replaced these with Ascii quotes. Nov 12, 2015 at 17:19

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.