ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / CanGetZs Method
Example

In This Topic
    CanGetZs Method
    In This Topic
    calling code must run on MCT
    Syntax
    public bool CanGetZs()
    Public Function CanGetZs() As Boolean

    Return Value

    True if this layer can be used by the GetZs methods, False otherwise
    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