This content has been marked as final. Show 5 replies
One has to go the numpy route?
Unfortunately, that seems to be the only solution for now. You might want to add your voice to the ArcGIS "wish list" at ideas.arcgis.com. An arc grid request has already been created. Click here for a direct link.
Thanks for the link - I have voted it up!
From this thread, in version 10
try the example
import numpy as np import arcpy #source http://forums.arcgis.com/threads/865-quot-built-in-quot-rasters-in-python-map-algebra #with some fiddling # Setup some rasters of rows and columns # (like old $$ROWMAP and $$COLMAP) arcpy.env.workspace = "c:/temp" arcpy.env.overwriteOutput = 1 nprows = np.indices((10,10)) npcols = np.indices((10,10)) # Convert the numpy arrays to ESRI rasters (ie Raster objects) # called 'rows' and 'cols' row_ras = arcpy.NumPyArrayToRaster(nprows) row_ras.save("rowraster") col_ras = arcpy.NumPyArrayToRaster(npcols) col_ras.save("colraster") print row_ras print col_ras
I found I can use the built in GRID variables or scalars in ArcGIS 10 with a bit of a hack. It appears that the python arcgisscripting module is still included in Desktop ArcGIS 10, perhaps for backwards compatibility (or perhaps I didn't uninstall 9.3 properly...), so I wrote a little script that uses the SingleOutputMapAlgebra tool, created a script tool and added that to a custom toolbox and then just use that as required.
import arcgisscripting gp = arcgisscripting.create(9.3) #This works in ArcGIS 10!!! expr=gp.getparameterastext(0) output=gp.getparameterastext(1) result=gp.SingleOutputMapAlgebra(expr,output)
I've attached a screenshot.
The best workaround I found in that environment was to compute flow accumulations for constant direction grids (and unit weights): $$ColMap is the flow accumulation of a grid filled with 1's and $$RowMap is the flow accumulation of a grid filled with 4's.
I did an implementation of this idea in arcpy map algebra here:
[post=288698]$$NCOLS + $$ROWMAP?[/post]