How to drape a layer on an elevation surface in globe


Summary
Floating layers define their place in 3D space by containing z-values in feature geometry, feature attributes, or layer level settings. This topic shows how to drape a layer on an elevation surface programmatically. This means that the layer will derive its elevation information from the specified raster and will not be draped onto the base globe surface. As a result, this layer is categorized as a floating layer.

Draping a layer on an elevation surface in globe

To drape a layer on an elevation surface in globe, do the following steps:
  1. Properly initialize the following variables:
    • ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay
    • ESRI.ArcGIS.Carto.ILayer layer—The layer to be draped on the elevation raster.
    • System.String elevationRasterFilePath—The path to the elevation raster file that is stored on disk.
  2. Get the IGlobeDisplayLayers interface from globeDisplay as shown in the following code example: 
[C#]
IGlobeDisplayLayers globeDisplayLayers = (IGlobeDisplayLayers)globeDisplay; 
    // Explicit cast.
[VB.NET]
Dim globeDisplayLayers As IGlobeDisplayLayers = CType(globeDisplay, IGlobeDisplayLayers) ' Explicit cast.
  1. Create the elevation raster (elevationRasterLayerCls) as shown in the following code example:
[C#]
IRasterLayer elevationRasterLayerCls = new RasterLayerClass();
elevationRasterLayerCls.CreateFromFilePath(elevationRasterFilePath);
[VB.NET]
Dim elevationRasterLayerCls As IRasterLayer = New RasterLayerClass()
elevationRasterLayerCls.CreateFromFilePath(elevationRasterFilePath)
  1. Create a variable of GlobeLayerPropertiesClass and set the type to elevation as shown in the following code example:
[C#]
ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerPropertiesCls = new
    ESRI.ArcGIS.GlobeCore.GlobeLayerPropertiesClass();
globeLayerPropertiesCls.Type =
    ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation;
[VB.NET]
Dim globeLayerPropertiesCls As IGlobeLayerProperties = New GlobeLayerPropertiesClass()
globeLayerPropertiesCls.Type = esriGlobeDataType.esriGlobeDataElevation
  1. Get the ILayerExtensions interface for the elevationRasterLayerCls and add to it the globeLayerPropertiesCls extension as shown in the following code example:
[C#]
ILayerExtensions layerExtension = (ILayerExtensions)elevationRasterLayerCls; 
    // Explicit cast.
layerExtension.AddExtension(globeLayerPropertiesCls);
[VB.NET]
Dim layerExtension As ILayerExtensions = CType(elevationRasterLayerCls, ILayerExtensions) ' Explicit cast.
layerExtension.AddExtension(globeLayerPropertiesCls)
  1. Get IGlobeLayerProperties for the layer to be draped on the elevation raster as shown in the following code example:
[C#]
IGlobeLayerProperties drapeLayerGlobeLayerProperties =
    globeDisplayLayers.FindGlobeProperties(layer);
[VB.NET]
Dim drapeLayerGlobeLayerProperties As IGlobeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer)
  1. Get IGlobeHeightProperties for the layer to be draped on the elevation raster as shown in the following code example:
[C#]
IGlobeHeightProperties drapeLayerGlobeHeightProperties =
    drapeLayerGlobeLayerProperties.HeightProperties;
[VB.NET]
Dim drapeLayerGlobeHeightProperties As IGlobeHeightProperties = drapeLayerGlobeLayerProperties.HeightProperties
  1. Set the base layer for drapeLayerGlobeHeightProperties to be the layer (elevationRasterLayerCls) as shown in the following code example:
[C#]
drapeLayerGlobeHeightProperties.BaseLayer = elevationRasterLayerCls;
[VB.NET]
drapeLayerGlobeHeightProperties.BaseLayer = elevationRasterLayerCls
  1. Set the base option for drapeLayerGlobeHeightProperties to be esriGlobeLayerBaseLayer as shown in the following code example:
[C#]
drapeLayerGlobeHeightProperties.BaseOption =
    ESRI.ArcGIS.GlobeCore.esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer;
[VB.NET]
drapeLayerGlobeHeightProperties.BaseOption = esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer
  1. Apply the height properties (drapeLayerGlobeHeightProperties) to the layer to be draped on the elevation raster (layer) as shown in the following code example:
[C#]
drapeLayerGlobeHeightProperties.Apply(globeDisplay.Globe, layer);
[VB.NET]
drapeLayerGlobeHeightProperties.Apply(globeDisplay.Globe, layer)
  1. Refresh the globeDisplay as shown in the following code example:
[C#]
globeDisplay.RefreshViewers();
[VB.NET]
globeDisplay.RefreshViewers()






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Advanced: 3D Analyst ArcGIS for Desktop Advanced: 3D Analyst
ArcGIS for Desktop Basic: 3D Analyst ArcGIS for Desktop Basic: 3D Analyst
ArcGIS for Desktop Standard: 3D Analyst ArcGIS for Desktop Standard: 3D Analyst
Engine Developer Kit Engine: 3D Analyst