1

I was trying to calculate Soil types based on the FAO's guidline using the Con tool in raster calculation with ArcGIS 10.3. from three layers (silt, clay & sand). But, I got an error saying:

Python syntax error:Parsing error SyntaxError: invalid syntax line1

I have put the code below. What is wrong with it?

OutRas = Con(("siltwtdavg" + 1.5*"claywtdavg")<15,1, Con(( "siltwtdavg"+ 1.5*"claywtdavg" >= 15) & (silt + 2*"claywtdavg" < 30),2, Con(("claywtdavg" >= 7 & "claywtdavg"< 20) & ("sand_av" > 52) & (("siltwtdavg" + 2*"claywtdavg") >= 30) | ("claywtdavg" < 7 & "siltwtdavg" < 50 & ("siltwtdavg"+2*"claywtdavg")>=30), 3, Con(("claywtdavg" >= 7 & "claywtdavg" < 27) & ("siltwtdavg" >= 28 & "siltwtdavg" < 50) & ("sand_av" <= 52),4, Con(("siltwtdavg" >= 50 & ("claywtdavg" >= 12 && "claywtdavg" < 27)) | (("siltwtdavg" >= 50 & "siltwtdavg" < 80) & "claywtdavg" < 12),5, Con("siltwtdavg" >= 80 & "claywtdavg" < 12, 6, Con(("claywtdavg" >= 20 && "claywtdavg" < 35) && ("siltwtdavg" < 28) && ("sand_av" > 45), 7, Con(("claywtdavg" >= 27 && "claywtdavg" < 40) && ("sand_av" > 20 && "sand_av" <= 45), 8, Con(("claywtdavg" >= 27 && "claywtdavg" < 40) && ("sand_av"  <= 20), 9, Con("claywtdavg" >= 35 && "sand_av" > 45), 10, Con("claywtdavg" >= 40 && "siltwtdavg" >= 40), 11, 12 )))))))))))
  • 1
    To start with, you have two extra parentheses at the end of the code. It takes patience to parse through such a long con statement. I advise you to use an illustrated editor that highlights corresponding open and closed parentheses to catch any syntax error. Notepad++ is one of the good ones. – yanes Jul 26 '16 at 17:28
1

To start with, you have two extra parentheses at the end of the code. It takes patience to parse through such a long con statement. I advise you to use an illustrated editor that highlights corresponding open and closed parentheses to catch any syntax error. Notepad++ is one of the good ones.

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.