Roteiro:
import arcpy, traceback, sys, os
pntFile=arcpy.GetParameterAsText(0)
rasters=arcpy.GetParameterAsText(1)
rasters=rasters.split(';')
theFields=[x.name.lower() for x in arcpy.ListFields(pntFile)]
result=arcpy.GetCount_management(pntFile)
nF=int(result.getOutput(0))
p=arcpy.Point()
try:
def showPyMessage():
arcpy.AddMessage(str(time.ctime()) + " - " + message)
for raster in rasters:
desc=arcpy.Describe(raster)
theFLD=raster.lower()
arcpy.AddMessage("Sampling "+theFLD)
if not(theFLD in theFields):
try:arcpy.AddField_management(pntFile, theFLD, "FLOAT")
except:
aF=raster.split(os.sep)[-1]
theFLD=aF.split(".")[0]
theFLD="F"+theFLD
arcpy.AddField_management(pntFile, theFLD, "FLOAT")
arcpy.SetProgressor("step", "", 0, nF)
with arcpy.da.UpdateCursor(pntFile,("SHAPE@XY",theFLD)) as rows:
for row in rows:
p.X,p.Y=row[0]
myArray = arcpy.RasterToNumPyArray(raster,p,1,1,-9999)
row[1]=myArray[0,0]
rows.updateRow(row)
arcpy.SetProgressorPosition()
del row,rows
except:
message = "\n*** PYTHON ERRORS *** "; showPyMessage()
message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
message = "Python Error Info: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()
Interface:
Parâmetros:
para trabalhar a partir de MXD. Atribua um nome exclusivo raster (s) à tabela de conteúdo. O script criará o mesmo campo de nome e tentará preenchê-lo com valores de célula.
É lento, então eu uso com menos de 1000 pontos