Here's an implementation of William Huber's neat idea of using the FlowAccumulation tool to generate xmap and ymap. This uses the current processing environment, it will generate an error if the arcpy.env.extent or cellSize are not explicitly set.
(this code has a bug fixed - thanks Cameron!
from arcpy.sa import *
from arcpy import env as E
# Calculate $$NROWS and $$NCOLS from current environment
cellSize = float(E.cellSize)
nrows = int((E.extent.YMax - E.extent.YMin) / float(E.cellSize))
ncols = int((E.extent.XMax - E.extent.XMin) / float(E.cellSize))
# Bill Huber's method for $$XMAP and $$YMAP: "1" flows "right", "64" (63+1) flows "up"
tmpg = CreateConstantRaster(1)
xmap = (FlowAccumulation(tmpg) + 0.5) * cellSize + E.extent.XMin
ymap = (FlowAccumulation(tmpg + 63) + 0.5) * cellSize + E.extent.YMin
# applying the same method for $$ROWMAP and $$COLMAP
colmap = Int(FlowAccumulation(tmpg))
rowmap = Int(FlowAccumulation(tmpg + 3)) # flowdir "4" is "down" (top row is 0)
It's always cool to see some of William Huber ideas revive!
Thanx for sharing Curtis Price
No problem, I was just resurrecting some old posts of mine, getting them tagged and placed in GeoNet where they will be easier to find.
Retrieving data ...