ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / GetZs Method / GetZs(Double,Double,SurfaceZsMissingHandler) Method
The x-coordinate
The y-coordinate
Provides options to handle missing Zs
Example

In This Topic
    GetZs(Double,Double,SurfaceZsMissingHandler) Method
    In This Topic
    Obtains a point geometry with Z for the specified x,y; where the Z value is populated from the layer. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Function GetZs( _
       ByVal x As Double, _
       ByVal y As Double, _
       ByVal missingHandler As SurfaceZsMissingHandler _
    ) As SurfaceZsResult

    Parameters

    x
    The x-coordinate
    y
    The y-coordinate
    missingHandler
    Provides options to handle missing Zs

    Return Value

    A result that contains a status, plus an output geometry only if the status is favorable.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The missingHandler will be used to determine what to do if the layer has no data at the particular input coordinate. The corresponding output geometry point or vertex Z will be set to the value specified in the provided missingHandler.OutputZ property. The missingHandler.OnlyProcessMissingZs parameter can be used to overwrite all Z values or only those that are designated as missing based on a comparison with the InputZ value.

    Use CanGetZs to determine if the layer can be used as an elevation source before calling this function.

    Example
    Get Z values from a layer
    {
        TinLayer tinLayer = map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
        //Note: This method must be called on the MCT
        MapPoint mapPoint = MapView.Active.Map.CalculateFullExtent().Center; //Any Map Point
        Polyline polyline = PolylineBuilderEx.CreatePolyline(mapView.Extent); //Any Polyline
    
        if (tinLayer.CanGetZs())
        {
            // get z value for a mapPoint
            var zResult = tinLayer.GetZs(mapPoint);
            if (zResult.Status == SurfaceZsResultStatus.Ok)
            {
                // cast to a mapPoint
                var mapPointZ = zResult.Geometry as MapPoint;
                var z = mapPointZ.Z;
            }
    
            // get z values for a polyline
            zResult = tinLayer.GetZs(polyline);
            if (zResult.Status == SurfaceZsResultStatus.Ok)
            {
                // cast to a mapPoint
                var polylineZ = zResult.Geometry as Polyline;
            }
        }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.4 or higher.
    See Also