ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SurfaceZsResultStatus Enumeration
Example Example

In This Topic
    SurfaceZsResultStatus Enumeration
    In This Topic
    Defines the status types resulting from calling Map.GetZsFromSurfaceAsync(). See SurfaceZsResult
    Syntax
    Members
    MemberDescription
    CalculationError Error: something went wrong when calculating, probably a SpatialReference issue.
    Canceled Information: the calculation was canceled, Zs are not available
    InvalidState Error: something went wrong internally.
    NoVisibleSourceThe specified ElevationSurfaceLayer has no visible elevation sources, all Zs were set to a constant value, Zs are available.
    Ok Calculation went fine, Zs are available.
    OutsideDomain Information: input is entirely outside the surface domain, Zs are not available.
    Example
    Get Elevation profile from the default ground surface
    {
        // get the elevation profile for a polyline / set of polylines
        Polyline polyline = PolylineBuilderEx.CreatePolyline();
        MapPoint mapPoint = MapPointBuilderEx.CreateMapPoint(34, -118, SpatialReferences.WGS84);
        List<MapPoint> mapPoints = new List<MapPoint> { mapPoint };
        var result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync([polyline]);
        if (result.Status == SurfaceZsResultStatus.Ok)
        {
            var polylineZ = result.Polyline;
    
            // process the polylineZ
    
            // get the elevation profile for a set of points
            result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(mapPoints);
            if (result.Status == SurfaceZsResultStatus.Ok)
            {
                polylineZ = result.Polyline;
                // process the polylineZ
            }
        }
    }
    Get Elevation profile from a specific surface
    {
        // find a specific elevation surface layer
        var eleLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
        Polyline polyline = PolylineBuilderEx.CreatePolyline();
        MapPoint mapPoint = MapPointBuilderEx.CreateMapPoint(34, -118, SpatialReferences.WGS84);
        List<MapPoint> mapPoints = new List<MapPoint> { mapPoint };
        // get the elevation profile for a polyline / set of polylines
        // use the specific elevation surface layer
        var zResult = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync([polyline], eleLayer);
        if (zResult.Status == SurfaceZsResultStatus.Ok)
        {
            var polylineZ = zResult.Polyline;
    
            // process the polylineZ
        }
    
        // get the elevation profile for a set of points
        // use the specific elevation surface layer
        zResult = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(mapPoints, eleLayer);
        if (zResult.Status == SurfaceZsResultStatus.Ok)
        {
            var polylineZ = zResult.Polyline;
    
            // process the polylineZ
        }
    }
    Interpolate a line between two points and calculate the elevation profile
    {
        int numPoints = 20;//Or any number of points you want to interpolate
                           // use a specific elevation surface
        var eleLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
        // use the default ground elevation surface
        MapPoint startPt = MapPointBuilderEx.CreateMapPoint(-130, 20, SpatialReferences.WGS84);
    
        MapPoint endPt = MapPointBuilderEx.CreateMapPoint(-100, 50, SpatialReferences.WGS84);
        var result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(startPt, endPt, numPoints);
        if (result.Status == SurfaceZsResultStatus.Ok)
        {
            var polylineZ = result.Polyline;
    
            // process the polylineZ
        }
        // use a specific elevation surface
        result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(startPt, endPt, numPoints, eleLayer);
        if (result.Status == SurfaceZsResultStatus.Ok)
        {
            var polylineZ = result.Polyline;
    
            // process the polylineZ
        }
    }
    Show Elevation profile graph using an ElevationProfileResult
    {
        MapPoint startPt = MapPointBuilderEx.CreateMapPoint(-130, 20, SpatialReferences.WGS84);
        MapPoint endPt = MapPointBuilderEx.CreateMapPoint(-100, 50, SpatialReferences.WGS84);
        var elevProfileResult = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(startPt, endPt, 10);
        if (elevProfileResult.Status != SurfaceZsResultStatus.Ok)
            return;
    
        if (!MapView.Active.CanShowElevationProfileGraph())
            return;
    
        // show the elevation profile using the result
        MapView.Active.ShowElevationProfileGraph(elevProfileResult);
    }
    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;
          }
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Mapping.SurfaceZsResultStatus

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also