Select to view content in your preferred language

ERROR 010328: Syntax error at or near symbol ).

9818
3
11-01-2011 08:39 AM
tomwaddington
Emerging Contributor
Hi im pretty new to python but im developing a code to identify automatic release zones for avalanches. i have the code working every time when i use the specific directory but when changing it to a generic directory so it can be used with different data sets with minimal changes other than changing the workspace i keep getting syntax errors ive managed to get the code working up to this point (shown below) but cant work out why it keeps presenting me with the error.

# Process: Release raster...
curv_plan_1 = workspace + "\\curv_plan_1"
slope = workspace + "\\slope"
dem_resample = workspace + "\\dem_resample"

InExpression1 = workspace + "\\rel_rast" + " = con((" + curv_plan_1 + " < 3) and (" + slope + " >= 30) and (" + slope + "<= 60) and (" + dem_resample + " > 900), 1, 0) "

print InExpression1

gp.MultiOutputMapAlgebra_sa(InExpression1)


Here is the print and error output that it comes with.

H:\Internship_Tom_Waddington\old_code\data\rel_rast = con((H:\Internship_Tom_Waddington\old_code\data\curv_plan_1 < 3) and (H:\Internship_Tom_Waddington\old_code\data\slope >= 30) and (H:\Internship_Tom_Waddington\old_code\data\slope<= 60) and (H:\Internship_Tom_Waddington\old_code\data\dem_resample > 900), 1, 0)
Traceback (most recent call last):
  File "H:\Internship_Tom_Waddington\old_code\codes\path_my_old_25a.py", line 79, in <module>
    gp.MultiOutputMapAlgebra_sa(InExpression1)
ExecuteError: ERROR 010328: Syntax error at or near symbol ).
ERROR 010267: Syntax error in parsing grid expression.
Failed to execute (MultiOutputMapAlgebra).
Tags (2)
0 Kudos
3 Replies
LornaMurison
Regular Contributor
I am not very familiar with map algebra, but it seems like you might need something like a comma in between your input files and the (<3, >=30 etc...) condition.
Like:
H:\Internship_Tom_Waddington\old_code\data\rel_rast =
 con((H:\Internship_Tom_Waddington\old_code\data\curv_plan_1, < 3) and
 (H:\Internship_Tom_Waddington\old_code\data\slope, >= 30) and
 (H:\Internship_Tom_Waddington\old_code\data\slope,<= 60) and
 (H:\Internship_Tom_Waddington\old_code\data\dem_resample, > 900), 1, 0)
0 Kudos
tomwaddington
Emerging Contributor
I tried what you suggested and now i get this error message.


('H:\\Internship_Tom_Waddington\\old_code\\data\\rel_rast = con((H:\\Internship_Tom_Waddington\\old_code\\data\\curv_plan_1', ' < 3) and (H:\\Internship_Tom_Waddington\\old_code\\data\\slope', ' >= 30) and (H:\\Internship_Tom_Waddington\\old_code\\data\\slope', '<= 60) and (H:\\Internship_Tom_Waddington\\old_code\\data\\dem_resample', ' > 900), 1, 0) ')
Traceback (most recent call last):
  File "H:\Internship_Tom_Waddington\old_code\codes\path_my_old_25a.py", line 79, in <module>
    gp.MultiOutputMapAlgebra_sa(InExpression1)
RuntimeError: Object: Error in executing tool
>>>
0 Kudos
LornaMurison
Regular Contributor
I've found that with things like the raster calculator, Arc is VERY finicky about syntax.  Things like not having spaces in between each argument can throw it off.
I would play around with it in the raster calculator until you can get it to work and then try again in python.
0 Kudos