ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / GetZs Method / GetZs(Geometry) Method
the input geometry
Example

In This Topic
    GetZs(Geometry) Method
    In This Topic
    Obtains a geometry that is similar to the given input geometry, where some or all Z values are populated from the layer. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Function GetZs( _
       ByVal geometry As Geometry _
    ) As SurfaceZsResult

    Parameters

    geometry
    the input geometry

    Return Value

    A result that contains a status, plus an output geometry only if the status is favorable.
    Exceptions
    ExceptionDescription
    The input geometry is null.
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If the layer has no data at a particular input geometry point, then the corresponding output geometry point Z will be set to the value specified in SurfaceZsMissingHandler.DefaultOutputZ.

    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
    var tinLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
    await QueuedTask.Run(() =>
    {
      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 = surfaceZResult.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 = surfaceZResult.Geometry as Polyline;
        }
      }
    });
    Get Z values from a TIN Layer
    var tinLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
    await QueuedTask.Run(() =>
    {
      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 Polyline
          var polylineZ = zResult.Geometry as Polyline;
        }
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also