Add Drape Layer to Globe Elevation Surface Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Add Drape Layer to Globe Elevation Surface Snippet

Drape a layer on an elevation surface.

[C#]
///<summary>Drape a layer on an elevation surface.</summary>
///      
///<param name="globeDisplay">An IGlobeDisplay interface</param>
///<param name="layer">An ILayer which is to draped on the globe</param>
///<param name="elevationRasterFilePath">A System.String that is the location of the elevation raster file. Example: "C:\temp\theElevationRaster"</param>
///      
///<remarks></remarks>
public void AddDrapeLayerToGlobeElevationSurface(ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay, ESRI.ArcGIS.Carto.ILayer layer, System.String elevationRasterFilePath)
{
  ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers globeDisplayLayers=(ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers)globeDisplay; // Explicit cast

  // Create elevation raster layer
  ESRI.ArcGIS.Carto.IRasterLayer elevationRasterLayer=new ESRI.ArcGIS.Carto.RasterLayerClass();
  elevationRasterLayer.CreateFromFilePath(elevationRasterFilePath);

  // Create and add the GlobeLayerProperties extension with the Type set to ElevationData
  ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProperties=new ESRI.ArcGIS.GlobeCore.GlobeLayerPropertiesClass();
  globeLayerProperties.Type=ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation;
  ESRI.ArcGIS.Carto.ILayerExtensions layerExtension=(ESRI.ArcGIS.Carto.ILayerExtensions)elevationRasterLayer; // Explicit cast
  layerExtension.AddExtension(globeLayerProperties);

  // Set the base option for layer to be esriGlobeLayerBaseLayer and its base layer to be ElevationLayer
  ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties drapeLayerGlobeLayerProperties=globeDisplayLayers.FindGlobeProperties(layer);
  ESRI.ArcGIS.GlobeCore.IGlobeHeightProperties drapeLayerGlobeHeightProperties=drapeLayerGlobeLayerProperties.HeightProperties;
  drapeLayerGlobeHeightProperties.BaseLayer=elevationRasterLayer;
  drapeLayerGlobeHeightProperties.BaseOption=ESRI.ArcGIS.GlobeCore.esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer;

  // Apply the height properties of the layer
  drapeLayerGlobeHeightProperties.Apply(globeDisplay.Globe, layer);
  globeDisplay.RefreshViewers();
}
[Visual Basic .NET]
'''<summary>Drape a layer on an elevation surface.</summary>
'''      
'''<param name="globeDisplay">An IGlobeDisplay interface</param>
'''<param name="layer">An ILayer which is to draped on the globe</param>
'''<param name="elevationRasterFilePath">A System.String that is the location of the elevation raster file. Example: "C:\temp\theElevationRaster"</param>
'''      
'''<remarks></remarks>
Public Sub AddDrapeLayerToGlobeElevationSurface(ByVal globeDisplay As ESRI.ArcGIS.GlobeCore.IGlobeDisplay, ByVal layer As ESRI.ArcGIS.Carto.ILayer, ByVal elevationRasterFilePath As System.String)

  Dim globeDisplayLayers As ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers=CType(globeDisplay, ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers) ' Explicit Cast

  '  Create elevation raster layer
  Dim elevationRasterLayer As ESRI.ArcGIS.Carto.IRasterLayer=New ESRI.ArcGIS.Carto.RasterLayerClass
  elevationRasterLayer.CreateFromFilePath(elevationRasterFilePath)

  ' Create and add the GlobeLayerProperties extension with the Type set to ElevationData
  Dim globeLayerProperties As ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties=New ESRI.ArcGIS.GlobeCore.GlobeLayerPropertiesClass
  globeLayerProperties.Type=ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation
  Dim layerExtension As ESRI.ArcGIS.Carto.ILayerExtensions=CType(elevationRasterLayer, ESRI.ArcGIS.Carto.ILayerExtensions) ' Explicit Cast
  layerExtension.AddExtension(globeLayerProperties)

  ' Set the base option for layer to be esriGlobeLayerBaseLayer and its base layer to be ElevationLayer
  Dim drapeLayerGlobeLayerProperties As ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties=globeDisplayLayers.FindGlobeProperties(layer)
  Dim drapeLayerGlobeHeightProperties As ESRI.ArcGIS.GlobeCore.IGlobeHeightProperties=drapeLayerGlobeLayerProperties.HeightProperties
  drapeLayerGlobeHeightProperties.BaseLayer=elevationRasterLayer
  drapeLayerGlobeHeightProperties.BaseOption=ESRI.ArcGIS.GlobeCore.esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer

  ' Apply the height properties of the layer
  drapeLayerGlobeHeightProperties.Apply(globeDisplay.Globe, layer)
  globeDisplay.RefreshViewers()

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.3DAnalyst
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.DataSourcesRaster
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.GlobeCore
  • ESRI.ArcGIS.System