Select to view content in your preferred language

internal grids rowmap/colmap/xmap/ymap

6539
6
12-03-2010 03:24 AM
HugoAhlenius
Deactivated User
Hi,

What is the latest on internal $$RowMap etc grids in ArcGIS 10? One has to go the numpy route?
0 Kudos
6 Replies
MannyGimond
Regular Contributor
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.
0 Kudos
HugoAhlenius
Deactivated User
Thanks for the link - I have voted it up!
0 Kudos
DanPatterson_Retired
MVP Emeritus
From this thread, in version 10
http://forums.arcgis.com/threads/865-quot-built-in-quot-rasters-in-python-map-algebra
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))[0]
npcols = np.indices((10,10))[1]
# 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
0 Kudos
Luke_Pinner
MVP Regular Contributor
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.
curtvprice
MVP Esteemed Contributor

Luke --  arcgisscripting is still there under arcpy. (You probably know this by know as this post was 2011!)

So this works (for now anyway).

import arcpy
arcpy.env.scratchWorkspace = r"D:\Users\cprice\work"
arcpy.CheckOutExtension("spatial")
arcpy.env.extent = arcpy.Extent(0, 0, 10, 10)
arcpy.env.cellSize = 1
arcpy.gp.SingleOutputMapAlgebra_sa("$$ROWMAP"), "rowmap")
curtvprice
MVP Esteemed Contributor
   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:
arcpy map algebra $$ROWMAP, $$COLMAP