You can determine the x,y,z dimensions using Raster, as described here.You can iterate over the dimensions and get the cell values, as described here.You can write to a file like this:f = 'D:\\temp\\test.txt'
with open(f, 'w') as fObj:
fObj.write('x, y, z\n')
for i in range(10):
fObj.write('%f, %f, %f\n % (i, i, i))
So, your overall code might be something like (have not tested):outTxt = 'D:\\temp\\test.txt'
inRasFP = 'D:\\temp\\raster.img'
inRas = arcpy.Raster(inRasFP)
extent = inRas.extent
with open(outTxt, 'w') as fObj:
fObj.write('x, y, z\n') # only if you want a header in the text file
for x in range(extent.XMin, extent.XMax):
for y in range(extent.YMin, extent.YMax):
fObj.write('%i, %i, %f\n % (x, y, arcpy.GetCellValue_management(inRasFP, "%i %i" % (x, y))))