Select to view content in your preferred language

Single Output Map Algebra - Error 010394 - Python

488
1
06-02-2010 08:12 AM
MichaelJust
Emerging Contributor
Hello,
I try the code below I get the following error:
Executing: SingleOutputMapAlgebra ((I:\giswork\mattandpeter\MD_ansense_001 + I:\
giswork\mattandpeter\MD_ansense_002 + I:\giswork\mattandpeter\MD_ansense_003) \
3) I:\giswork\mattandpeter\MDE_001test #
Start Time: Wed Jun 02 10:59:15 2010
Failed to execute. Parameters are not valid.
ERROR 010394: Map Algebra expression: Syntax error at location 1 (around (I:\g)
of expression ((I:\giswork\mattandpeter\MD_ansense_001 + I:\giswork\mattandpeter
\MD_ansense_002 + I:\giswork\mattandpeter\MD_ansense_003) \ 3).
Failed to execute (SingleOutputMapAlgebra).
End Time: Wed Jun 02 10:59:15 2010 (Elapsed Time: 0.00 seconds)


However, this command works fine in Raster Calculator.  I don' t know what's wrong with my syntax for SOMA.  I've tried forward and back slashes.  Any ideas on how I can get this to work? Or why its not working?

Thanks,
Mike

import arcgisscripting
from datetime import datetime 
# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
    # Set local variables
    gp.AddMessage("\n" + "Begin Calculating" + "\n")
    InExpression = "((I:\giswork\mattandpeter\MD_anse\anse_001 + I:\giswork\mattandpeter\MD_anse\anse_002 + I:\giswork\mattandpeter\MD_anse\anse_003) \ 3)"
    OutRaster = "I:\giswork\mattandpeter\MDE_001test"
    gp.AddMessage(str(datetime.now()))
    

    # Check out Spatial Analyst extension license
    gp.CheckOutExtension("Spatial")

    # Process: MapAlgebraStatement
    gp.SingleOutputMapAlgebra_sa(InExpression, OutRaster)
    gp.AddMessage(str(datetime.now()))

except:
    # If an error occurred while running a tool, then print the messages.
    print gp.GetMessages()
0 Kudos
1 Reply
MichaelJust
Emerging Contributor
Whoops.

Firstly, "divide" is '/' not '\' . Also, there are some escape sequences in the raster names. This necessitates "\\"

Cheers,
Michael
0 Kudos