English

How To: Extract Z values of a raster layer to a point shapefile

Summary

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.

Procedure

  1. Add the point shapefile and the surface to a map, making certain the point featureclass is listed first in the table of contents.

    Note:
    The point shapefile and raster must share the same coordinate system.

  2. Add a numeric field to the point attribute table.
  3. Right-click the new field heading > Calculate Values. Check the Advanced box.
  4. In the pre-logic script edit box enter:

    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

  5. In the '<new fieldname> =' box enter:

    Code:
    iPixelValue

  6. Click OK and the raster Z values are added to the attribute field.