I am trying to rewrite some v9.3 SingleOutputMapAlgebra Python code in v10.0. Basically I have a bunch of rasters called "nst_*" (example: nst_lp_1, nst_lp2, nst_lp_3, ...) that have an integer field in their attribute tables called "NST", and I am wanting to produce a single output raster that represents the maximum "NST" value of all the input rasters. In v9.3 this was easy using dot notation and string SOMA string construction... But now in v10 I am running into some issues with the confounded Lookup() tool and how to best do this in an efficient manner. My v9.3 code:#Process: Produce a grid that is the max nesting habitat value from all scenarios and all decades
maxString = ""
gp.workspace = root
gridList = gp.listrasters("nst_*")
for grid in gridList:
maxString = maxString + grid + ".NST" + ","
somaExp = "max(" + maxString[:-1] + ")"
maxNestingScoreGrd = root + "\\max_nesting"
gp.SingleOutputMapAlgebra_sa(somaExp, maxNestingScoreGrd, "")
BTW: I know I have to replace good ole' max() with CellStatistics()... max() is no longer with us.Basically, I'm looking for an clean way to incorporate the lookup() function in a loop inside another function... Any one have ideas how to do this elegantly in v10.0 synax?