I have raster bathymetry data that i would like to extract the x,y,z values from, whilst also ignoring No Data cells (which on narrow survey passes at a 45° angle to North can be over half the data points). I am an experienced ArcMap 9.3.1 end user but a little rough around the gills in writing Python 2.5 scripts. However I have come up with the following:import arcgisscripting
gp = arcgisscripting.create()
InRaster = "C:\JPL_Jobs\XYZ_TEST\AreaTest2_Clip.img"
wf = open('C:\JPL_Jobs\XYZ_TEST\Create_Test_xyz.txt','w')
Cellsize = gp.GetRasterProperties(InRaster, "CELLSIZEX")
Xul = gp.GetRasterProperties(InRaster, "LEFT")
Yul = gp.GetRasterProperties(InRaster, "TOP")
Ht = gp.GetRasterProperties(InRaster, "ROWCOUNT")
Wd = gp.GetRasterProperties(InRaster, "COLUMNCOUNT")
wf.write("x,y,z\n")
try:
for j in range(int(Ht)):
for i in range(int(Wd)):
XValue = Xul + ((Cellsize * i) + (Cellsize / 2))
YValue = Yul - ((Cellsize * j) + (Cellsize / 2))
XValueStr = str(XValue)
YValueStr = str(YValue)
d = XValueStr + " " + YValueStr
cellVal = gp.GetCellValue_management(InRaster, d)
if cellVal <> "NoData" :
cellValStr = str(cellVal)
lineval = XValueStr + ", " + YValueStr + ", " + cellValStr + "\n"
wf.write(lineval)
except:
print gp.GetMessages()
wf.close()
print "Finished"
This works but my question is, on a very small 6x6 grid it took 11 secs. I am currently looking at a 9400 x 9300 bathymetry raster (a typical size) and wonder whether using this method just simply won't be up to the task, taking far too long to process? Or am I going about this task in the wrong way? I have used the Raster2xyz vba script in the past which has worked fine but i believe ArcGIS 10 is not supporting VB. Our team is switching soon but I am not keen (just yet!).As an aside, typing 9.3 into arcgisscripting.create() caused the script to fail. Any thoughts on why that might be?Thank you in advanceJohn