请教:vba获取栅格图层的所有栅格的值
代码如下:
Private Sub UIButtonControl1_Click()
Dim mydoc As IMxDocument
Set mydoc = ThisDocument
Dim mylayer As IRasterLayer
Set mylayer = mydoc.selectedlayer
MsgBox mylayer.Name, 0, "图层名"
Dim rasterprops As IRasterProps
Set rasterprops = mylayer.Raster
Dim dheight, dwidth As Integer
dheight = rasterprops.Height
dwidth = rasterprops.Width
MsgBox dheight & Space(2) & dwidth, 0, "高度和宽度"
Dim dx, dy As Double
dx = rasterprops.MeanCellSize.x
dy = rasterprops.MeanCellSize.y
MsgBox dx & Space(2) & dy, 0, "采样间隔"
Dim extent As IEnvelope
Set extent = rasterprops.extent
Dim pixeltype As rstPixelType
pixeltype = rasterprops.pixeltype
Dim pntsize As IPnt
pntsize.SetCoords dx, dy
Dim pixelblock As IPixelBlock3
Set pixelblock = mylayer.Raster.CreatePixelBlock(pntsize)
Dim pnt As IPnt
Dim i, j As Integer
Dim obj As Object
Dim form As IFormatTest
For i = 1 To dheight
For j = 1 To dwidth
pnt.SetCoords i, j
mylayer.Raster.Read pnt, pixelblock
If pixelblock Is Not Null Then
obj = pixelblock.GetVal(0, 0, 0)
MsgBox obj
End If
Next j
Next i
End Sub
其中最后两句没有写完,不知道用getval读到的栅格值怎么显示出来
运行出现run-time error‘91’的提示
请大家帮忙