Select to view content in your preferred language

Implementing neighborhood notation in Arc 10?

593
2
04-29-2011 09:43 AM
curtvprice
MVP Alum
Does anyone know if the following docell code can be done with map algebra in ArcGIS 10?

docell
if (flr_ezg eq 1) to_flg_lg = flg_lg_ezg(1,0)
if (flr_ezg eq 2) to_flg_lg = flg_lg_ezg(1,1)
if (flr_ezg eq 4) to_flg_lg = flg_lg_ezg(0,1)
if (flr_ezg eq 😎 to_flg_lg = flg_lg_ezg(-1,1)
if (flr_ezg eq 16) to_flg_lg = flg_lg_ezg(-1,0)
if (flr_ezg eq 32) to_flg_lg = flg_lg_ezg(-1,-1)
if (flr_ezg eq 64) to_flg_lg = flg_lg_ezg(0,-1)
if (flr_ezg eq 128) to_flg_lg = flg_lg_ezg(1,-1)
end

I would like to code in arcobjects c# with map algebra. I have read about numpy array as one way to do it in python.

Thanks for any help

Bruce Vandenberg


Bruce, Neighborhood notation is not supported at Arc 10. We've been asking. Please do contact tech support on this. They may send you to using numpy rasters to do this kind of thing.

Another workaround may possibly to use the MultiOutputMapAlgebra tool, but it isn't supported at 10.0 although it is still there in the gp object.

You may be able to work out something using the Shift tool to offset a bunch of rasters and then use Pick to select the right one from the list. You can convert the powers of two to 1...8 using this map algebra expression. This could be used with Pick.

(Log2(flr_ezg) + 1)

Hope this helps you out!
0 Kudos
2 Replies
RobEllis
Deactivated User
Curtis, you say that MultiOutputMapAlgebra is still there in the 'gp' object (ESRI.ArcGIS.Geoprocessor.Geoprocessor??) - any chance of an example of how to use this? I have an old VB .NET implementation that used to be used to produce a bunch of output rasters from multiple 'mosaic' processes, using 'ESRI.ArcGIS.SpatialAnalystTools.MultiOutputMapAlgebra' as the input to a gp.Execute statement. I just can't see how I convert my use of ESRI.ArcGIS.SpatialAnalystTools.MultiOutputMapAlgebra to standard Geoprocessor syntax, and can't find a step-through example. Would appreciate your help.

Rob
0 Kudos
curtvprice
MVP Alum
I just saw this sorry. I'm not much help because I have no expertise with ArcObjects.

About MOMA, I just checked and it still can be used at 10.1, and it still seems to support neighborhood notation. here's an example:

>>> expr = "tmp3 = tmp1(0,1)"
>>> r = arcpy.gp.MultiOutputMapAlgebra_sa(expr)
>>> print arcpy.GetMessages(0)
Executing: MultiOutputMapAlgebra "tmp3 = tmp1(1,1)"
Start Time: Thu Aug 08 17:27:30 2013
Succeeded at Thu Aug 08 17:27:30 2013 (Elapsed Time: 0.00 seconds)
>>> r = arcpy.gp.MultiOutputMapAlgebra_sa("print tmp3")
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
1 1 1 1 1 1 1 1 1 NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
>>>


Here's how your example would work using con (the old, awesome, CON function, not the new, dumb Con tool).

expr = """
{2} = con(
{0} eq 1, {1}(1,0),
{0} eq 2, {1}(1,1),
{0} eq 4, {1}(0,1),
{0} eq 8, {1}(-1,1),
{0} eq 16, {1}(-1,0),
{0} eq 32, {1}(-1,-1),
{0} eq 64, {1}(0,-1),
{0} eq 128, {1}(1,-1))
""".format("flr_ezg","flg_lg_ezg","to_flg_lg")
arcpy.gp.MultiOutputMapAlgebra(expr.replace("\n",""))


Remember it is very limited (grids only, no project on the fly, etc etc) - but could be very handy if you run across a problem that was easy but stumping you in the newfangled arcpy.

(No support -- and no guarantee it will work beyond 10.2 however!)

Would be really interesting to do some performance testing vs arcpy!
0 Kudos