HOW TO
This document will demonstrate how to determine the accurate X,Y,Z values from a Raster layer using a mouse click.
Code:
Private Sub RasterIdentifyTool_MouseDown(ByVal button As Long, ByVal shift As
Long, ByVal x As Long, ByVal y As Long)
Dim pMxDoc As IMxDocument
Dim pRasLyr As IRasterLayer
Dim pRasRen As IRasterRenderer
Dim pIdentify As IIdentify
Dim pArray As IArray
Dim pPoint As IPoint
Dim pGeom As IGeometry
Dim pRasID As IRasterIdentifyObj
Set pMxDoc = ThisDocument
Set pPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
Set pGeom = pPoint
Set pRasLyr = pMxDoc.FocusMap.Layer(0)
Set pRasRen = pRasLyr.Renderer
Set pIdentify = pRasLyr 'Test RasterLayer
'Set pIdentify = pRasRen 'Test RasterRenderer
Set pArray = pIdentify.Identify(pGeom)
If TypeOf pArray.Element(0) Is IRasterIdentifyObj Then
Set pRasID = pArray.Element(0)
Else
MsgBox "failed"
Exit Sub
End If
MsgBox pRasID.MapTip, , pRasID.Location.x & "," & pRasID.Location.y
End Sub
Code:
stretched renderer returns - pixel value
rgb renderer returns - r, g, b values
classified renderer returns - pixel value
unique value renderer returns - OID
Get help from ArcGIS experts
Download the Esri Support App