AnsweredAssumed Answered

Map Algebra in v10

Question asked by csny490 on Mar 6, 2012
Latest reply on Mar 8, 2012 by csny490
Struggling with "best" Map Algebra syntax to use in scripts via PythonWin (NOT the Python window in ArcGIS, which seems to allow for different syntax - which is confussingm, but off topic)...

Anyway... Classic "make streams from flow accumulation" scenario...

In v9.3 I could do this:
flowAccGrd = "flow_acc" flowDirGrd = "flow_dir" somaExp = "streamlink(con(" + flowAccGrd + " > 500, 1, setnull(1)), " + flowDirGrd + ")" streamLinkGrd = "stream_link" gp.SingleOutputMapAlgeba_sa(somaExp, streamLinkGrd)


Solid...

Now as I try to rewrite some stuff in the new v10 syntax, the best I can com up with is this:
flowAccGrd = "flow_acc" flowDirGrd = "flow_dir" streamLinkTmp = arcpy.sa.StreamLink(arcpy.sa.Con(flowAccGrd, 1, arcpy.sa.SetNull(1,1), "VALUE >= 500")), flowDirGrd) streamLinkGrd = "stream_link" streamLinkTmp.save(streamLinkGrd)


Is there a better/more compact way to write this expresion ini v10 sytax (again, writting for a "stand-alone script")?

Is that imbedded arcpy.sa.SetNull(1,1) neccessary - or is there a more elegant way to use the IsNull() and SetNull() expressions inside of a con() statement... Seemed easier in v9.3.

Outcomes