ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / GetElevationProfileGraph Method
Example

In This Topic
    GetElevationProfileGraph Method
    In This Topic
    Gets the elevation profile graph for the mapView. This may return null if no elevation profile graph is visible.
    Syntax
    public ElevationProfileGraph GetElevationProfileGraph()
    Public Function GetElevationProfileGraph() As ElevationProfileGraph

    Return Value

    Example
    Access the ElevationProfileGraph when added
    public void ElevationProfileGraphAdded()
    {
    
      var mv = MapView.Active;
      // subscribe to the Added, Removed events for the elevation profile graph
      mv.ElevationProfileGraphAdded += Mv_ElevationProfileGraphAdded;
      mv.ElevationProfileGraphRemoved += Mv_ElevationProfileGraphRemoved;
    
    }
    
    private void Mv_ElevationProfileGraphRemoved(object sender, EventArgs e)
    {
      ;
    }
    
    private void Mv_ElevationProfileGraphAdded(object sender, EventArgs e)
    {
      // get the elevation profile graph from the view
      // this will be non-null since we are in a ElevationProfileGraphAdded handler
      var mv = MapView.Active;
      var graph = mv.GetElevationProfileGraph();
    
      // subscribe to the ContentLoaded event
      graph.ContentLoaded += Graph_ContentLoaded;
    }
    
    private void Graph_ContentLoaded(object sender, EventArgs e)
    {
      // get the elevation profile graph
      var graph = sender as ArcGIS.Desktop.Mapping.ElevationProfileGraph;
    
      // get the elevation profile geometry
      var polyline = graph.Geometry;
      // get the elevation profile statistics
      var stats = graph.ElevationProfileStatistics;
    }
    Access the ElevationProfileGraph
    var elevProfileGraph = MapView.Active.GetElevationProfileGraph();
    // Elevation profile graph will be null if no profile graph is displayed
    if (elevProfileGraph == null)
      return;
    
    // get the elevation profile geometry and stats
    var polyline = elevProfileGraph.Geometry;
    var stats = elevProfileGraph.ElevationProfileStatistics;
    
    // reverse the graph
    elevProfileGraph.IsReversed = !elevProfileGraph.IsReversed;
    
    // collapse the graph
    elevProfileGraph.IsExpanded = false;
    Export Elevation Profile Graph
    var elevProfileGraph = MapView.Active.GetElevationProfileGraph();
    // Elevation profile graph will be null if no profile graph is displayed
    if (elevProfileGraph == null)
      return;
    
    if (elevProfileGraph.CanExport)
    {
      elevProfileGraph.ExportToImage("c:\\temp\\myprofileImage.png");
      elevProfileGraph.ExportToCSV("c:\\temp\\myprofile.csv");
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also