Help on creating profile graphs from transects?

Discussion created by wilmermenjivar on Nov 13, 2013
Latest reply on Nov 14, 2013 by wilmermenjivar
Okay so, I am working on ArcGIS 10.1, and Visual Studio 2010.

My objective is to build an add-in that allows for a user to push a button and create a transect (line) in ArcGIS. That line will
profile graph. I know you can do this with 3D analyst, however 3D analyst does not output more than one graph at a time if you
have multiple rasters or GRIDS. So I want to be able to have 3 rasters on and create a transect and that transect will output 3 different profiles but of the same line. So far, I have been able to build the add-in up to the point of creating the line. So the code below  allows you to draw a line. But now I am stuck in how do I make this line interpolate the data from each raster and output a separate graph?

using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Lab5
    public class Tool1 : ESRI.ArcGIS.Desktop.AddIns.Tool
        public Tool1()

#region "Add Graphic to Map"

///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
///<param name="map">An IMap interface.</param>
///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param>
///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param>
///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
public void AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor)
  IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
  IElement element = null;
  if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint)
    // Marker symbols
    ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
    simpleMarkerSymbol.Color = rgbColor;
    simpleMarkerSymbol.Outline = true;
    simpleMarkerSymbol.OutlineColor = outlineRgbColor;
    simpleMarkerSymbol.Size = 15;
    simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

    IMarkerElement markerElement = new MarkerElementClass();
    markerElement.Symbol = simpleMarkerSymbol;
    element = (IElement)markerElement; // Explicit Cast
  else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolyline)
    //  Line elements
    ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
    simpleLineSymbol.Color = rgbColor;
    simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
    simpleLineSymbol.Width = 5;

    ILineElement lineElement = new LineElementClass();
    lineElement.Symbol = simpleLineSymbol;
    element = (IElement)lineElement; // Explicit Cast
  else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolygon)
    // Polygon elements
    ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
    simpleFillSymbol.Color = rgbColor;
    simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal;
    IFillShapeElement fillShapeElement = new PolygonElementClass();
    fillShapeElement.Symbol = simpleFillSymbol;
    element = (IElement)fillShapeElement; // Explicit Cast
  if (!(element == null))
    element.Geometry = geometry;
    graphicsContainer.AddElement(element, 0);

#region "Get Polyline From Mouse Clicks"

///Create a polyline geometry object using the RubberBand.TrackNew method when a user click the mouse on the map control. 
///<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that will user will interace with to draw a polyline.</param>
///<returns>An ESRI.ArcGIS.Geometry.IPolyline interface that is the polyline the user drew</returns>
///<remarks>Double click the left mouse button to end tracking the polyline.</remarks>
public IPolyline GetPolylineFromMouseClicks(IActiveView activeView)

  IScreenDisplay screenDisplay = activeView.ScreenDisplay;

  IRubberBand rubberBand = new RubberLineClass();
  IGeometry geometry = rubberBand.TrackNew(screenDisplay, null);

  IPolyline polyline = (IPolyline)geometry;

  return polyline;


        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs
    //Get the active view from the ArcMap static class.
    IActiveView activeView = ArcMap.Document.ActiveView;

    //If it's a polyline object, get from the user's mouse clicks.
    IPolyline polyline = GetPolylineFromMouseClicks(activeView);

    //Make a color to draw the polyline. 

    IRgbColor rgbColor = new RgbColorClass();
    rgbColor.Green = 255;

    //Add the user's drawn graphics as persistent on the map.

    AddGraphicToMap(activeView.FocusMap, polyline, rgbColor, rgbColor);

    //Best practice: Redraw only the portion of the active view that contains graphics. 
    activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

        protected override void OnUpdate()
            Enabled = ArcMap.Application != null;