ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SurfaceZsResult Class
Members Example

In This Topic
    SurfaceZsResult Class
    In This Topic
    Defines the result of calling Map.GetZsFromSurfaceAsync()
    Object Model
    SurfaceZsResult ClassGeometry Class
    Syntax
    public sealed class SurfaceZsResult 
    Public NotInheritable Class SurfaceZsResult 
    Example
    Get Z values from the default ground surface
    {
      var surfaceZResult = await QueuedTask.Run(async () =>
      {
        // Get the center of the map's full extent
        MapPoint mapPoint = map.CalculateFullExtent().Center;
        //Pass any Geometry type to GetZsFromSurfaceAsync
        return await map.GetZsFromSurfaceAsync(mapPoint);
      });
      if (surfaceZResult.Status == SurfaceZsResultStatus.Ok)
      {
        // cast to a mapPoint
        var mapPointZ = surfaceZResult.Geometry as MapPoint;
        var z = mapPointZ.Z;
      }
    }
    Get Z values from a specific surface
    {
      await QueuedTask.Run(async () =>
      {
        var eleLayer = map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
        //Pass any Geometry type to GetZsFromSurfaceAsync
        //Ensure the feature layer is a line layer and is Z aware
        var selectedFeatures = featureLayer.GetSelection();
        var rowCursor = selectedFeatures.Search();
        while (rowCursor.MoveNext())
        {
          var feature = rowCursor.Current as Feature;
          var polyline = feature.GetShape() as Polyline;
          var zResult = await map.GetZsFromSurfaceAsync(polyline, eleLayer);
          if (zResult.Status == SurfaceZsResultStatus.Ok)
          {
            var polylineZ = zResult.Geometry as Polyline;
            // process the polylineZ
            // For example, you can iterate through the points and access their Z values
          }
        }
      });
    }
    Get Z values from a layer
    {
      await QueuedTask.Run(() =>
      {
        TinLayer tinLayer = map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
        MapPoint mapPoint = 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
    {
      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;
          }
        }
      });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.SurfaceZsResult

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also