I'm guessing this is related to your issue, but a while back I reported a bug to ESRI:When you set a snaperaster in a Python script, the SA tools all perform significantly slower (compared to if you don't set it).The ESRI fellow noted the slowdown, but didn't seem to understand why this was a big deal, and wanted to close the "incident" right away ( incident #807205 BTW)... Maybe they get incentive pay for "number of closed incidents"? Hmm...Anyway, in ancient times (pre v9.2), before the gp.snapraster function worked (at all), I wrote a function that adjusted a given gp.extent to the cell alignment of a given raster (see code below). Basically this is what gp.snapraster is doing behind the scenes... Upon finding the aforementioned bug in v9.3, I resurrected my code, and happily use it to this day. Probably more verbose than necessary, but it works great... Might require some small re-writes for v10.def snapExtentToRaster(inputExtent, snapRaster):
"Returns a xMin, yMin, xMax, yMax extent snapped to the cell allignment of a raster"
xMinInput = float(inputExtent.split(" ")[0])
yMinInput = float(inputExtent.split(" ")[1])
xMaxInput = float(inputExtent.split(" ")[2])
yMaxInput = float(inputExtent.split(" ")[3])
dscSnapRaster = gp.describe(snapRaster)
cellSize = float(dscSnapRaster.meancellheight)
xMinSnap = float(dscSnapRaster.extent.xmin)
yMinSnap = float(dscSnapRaster.extent.ymin)
xMaxSnap = float(dscSnapRaster.extent.xmax)
yMaxSnap = float(dscSnapRaster.extent.ymax)
#Calculates a modified xMinInput
if xMinSnap < xMinInput:
if divmod(abs(xMinInput - xMinSnap), cellSize)[1] / cellSize < .5:
xMinOutput = xMinSnap + divmod(abs(xMinInput - xMinSnap), cellSize)[0] * cellSize
else:
xMinOutput = xMinSnap + cellSize + divmod(abs(xMinInput - xMinSnap), cellSize)[0] * cellSize
else:
if divmod(abs(xMinInput - xMinSnap), cellSize)[1] / cellSize < .5:
xMinOutput = xMinSnap - divmod(abs(xMinInput - xMinSnap), cellSize)[0] * cellSize
else:
xMinOutput = xMinSnap - cellSize - divmod(abs(xMinInput - xMinSnap), cellSize)[0] * cellSize
#Calculates a modified yMinInput
if yMinSnap < yMinInput:
if divmod(abs(yMinInput - yMinSnap), cellSize)[1] / cellSize < .5:
yMinOutput = yMinSnap + divmod(abs(yMinInput - yMinSnap), cellSize)[0] * cellSize
else:
yMinOutput = yMinSnap + cellSize + divmod(abs(yMinInput - yMinSnap), cellSize)[0] * cellSize
else:
if divmod(abs(yMinInput - yMinSnap), cellSize)[1] / cellSize < .5:
yMinOutput = yMinSnap - divmod(abs(yMinInput - yMinSnap), cellSize)[0] * cellSize
else:
yMinOutput = yMinSnap - cellSize - divmod(abs(yMinInput - yMinSnap), cellSize)[0] * cellSize
#Calculates a modified xMaxInput
if xMaxSnap < xMaxInput:
if divmod(abs(xMaxInput - xMaxSnap), cellSize)[1] / cellSize < .5:
xMaxOutput = xMaxSnap + divmod(abs(xMaxInput - xMaxSnap), cellSize)[0] * cellSize
else:
xMaxOutput = xMaxSnap + cellSize + divmod(abs(xMaxInput - xMaxSnap), cellSize)[0] * cellSize
else:
if divmod(abs(xMaxInput - xMaxSnap), cellSize)[1] / cellSize < .5:
xMaxOutput = xMaxSnap - divmod(abs(xMaxInput - xMaxSnap), cellSize)[0] * cellSize
else:
xMaxOutput = xMaxSnap - cellSize - divmod(abs(xMaxInput - xMaxSnap), cellSize)[0] * cellSize
#Calculates a modified yMaxInput
if yMaxSnap < yMaxInput:
if divmod(abs(yMaxInput - yMaxSnap), cellSize)[1] / cellSize < .5:
yMaxOutput = yMaxSnap + divmod(abs(yMaxInput - yMaxSnap), cellSize)[0] * cellSize
else:
yMaxOutput = yMaxSnap + cellSize + divmod(abs(yMaxInput - yMaxSnap), cellSize)[0] * cellSize
else:
if divmod(abs(yMaxInput - yMaxSnap), cellSize)[1] / cellSize < .5:
yMaxOutput = yMaxSnap - divmod(abs(yMaxInput - yMaxSnap), cellSize)[0] * cellSize
else:
yMaxOutput = yMaxSnap - cellSize - divmod(abs(yMaxInput - yMaxSnap), cellSize)[0] * cellSize
#Returns the entire modified extent
return str(xMinOutput) + " " + str(yMinOutput) + " " + str(xMaxOutput) + " " + str(yMaxOutput)
#Example of use.... adjuest the extent of oesfBufferFC so it aligns with gnnReadGrd
oesfBufferFC = fgdbPath + "\\oesf_buffer"
gnnReadGrd = r"\\dnrutoly05\d$\csny490\gnn_20100303\mr200_sppsz_2006\gnn_20100303"
gp.extent = oesfBufferFC
gp.extent = snapExtentToRaster(gp.extent, gnnReadGrd)