HOW TO
Instructions provided describe how to extract Z values from a raster surface and write them into a point shapefile attribute table with the field calculator. In ArcGIS 9.0, the Spatial Analyst Geoprocessing Toolbox has a tool called Extract Values to Points, which produces the same output.
Note:
The point shapefile and raster must share the same coordinate system.
Code:
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pRLayer As IRasterLayer
Dim pIdentify As IIdentify
Dim pIDArray As IArray
Dim pRIDObj As IRasterIdentifyObj
Dim pPoint As IPoint
Dim iPixelValue As Integer
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pRLayer = pMap.Layer(1)
Set pIdentify = pRLayer
Set pPoint = New Point
'Get point
Set pNewPoint = [Shape]
Set pIDArray = pIdentify.Identify(pNewPoint)
If Not pIDArray Is Nothing Then
Set pRIDObj = pIDArray.Element(0)
'Get the value of the RasterIdentifyObject and add it to the field
iPixelValue = pRIDObj.Name
End If
Code:
iPixelValue
Article ID:000006748
Get help from ArcGIS experts
Download the Esri Support App