Python scripting access to SOMA and MOMA from 10.x

3595
3
05-17-2010 11:21 AM
curtvprice
MVP Esteemed Contributor
I have an old script that uses MOMA and want to be able to run it at 10.x until I get around to doing it the new, (better) way.

I tried

import arcpy...
import arcgisscripting
gp = arcgisscripting.create()
gp.MultiOutputMapAlgebra_sa()  # error ("<s> not found")


and get an error that the tool does not exist.

The docs talk about legacy access to MOMA inside model tools, but is there a way to get to SOMA and MOMA in python?
0 Kudos
3 Replies
XuguangWang
Esri Contributor

Curtis,

The following script worked for me:

import arcgisscripting
gp = arcgisscripting.create()

gp.checkoutextension("spatial")

gp.workspace = "c:/temp/work"
in_raster1 = "C:/sapyexamples/data/inRas1"
in_raster2 = "C:/sapyexamples/data/inRas2"

express1 = "out1 = " + in_raster1 + " + " + in_raster2
gp.MultiOutputMapAlgebra_sa(express1)

A few points to consider when you run MOMA with arcgisscripting:
1. Control output workspace
2. Check out spatial analyst license
3. For MOMA expression, supply the output dataset name on the left side of '='.

Thanks,
Xuguang Wang

0 Kudos
curtvprice
MVP Esteemed Contributor
Thanks, it looks like I had forgotten to check out the Spatial extension on my 9.3 geoprocessor object. (I had checked it out to my arcpy object in the test script -- and forgot to do the same for my "gp" object.)

It's working fine - good to have that legacy support while we move to the brave new world of arcpy -- just in case we need it!
0 Kudos
curtvprice
MVP Esteemed Contributor

I have since discovered that this works. Just adding it here for the good of the thread

arcpy.gp.MultiOutputMapAlgebra_sa(cmd)

0 Kudos