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

In This Topic
    CanGetZs Method
    In This Topic
    Determines whether the layer can be used as an elevation source to retrieve Z values for geometries. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function CanGetZs() As Boolean
    public bool CanGetZs()

    Return Value

    True if this layer can be used by the GetZs methods, False otherwise
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    Not all layers can be used as an elevation source. Typically TINs and some rasters are supported. Also some image service files that support non-binary levels of detail.
    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;
            }
        }
    }
    Get Z values from a TIN Layer
    {
      // Note: Needs QueuedTask to 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.4 or higher.
    See Also