ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / TerrainLayer Class
Members Example

In This Topic
    TerrainLayer Class
    In This Topic
    Represents a Terrain layer.
    Object Model
    TerrainLayer ClassCIMTinRenderer ClassCIMDataConnection ClassTimeExtent ClassCIMBaseLayer ClassElevationTypeDefinition ClassLineOfSightResult ClassSpatialReference ClassTerrain ClassTimeParameters ClassMap ClassILayerContainer InterfaceEnvelope Class
    Syntax
    Example
    Retrieve layers
    // find the first TIN layer
    var tinLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
    
    // find the first Terrain layer
    var terrainLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<TerrainLayer>().FirstOrDefault();
    
    // find the first LAS dataset layer
    var lasDatasetLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<LasDatasetLayer>().FirstOrDefault();
    
    // find the set of surface layers
    var surfacelayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<SurfaceLayer>();
    Create a TerrainLayer
    //Must be on the QueuedTask.Run()
    
    string terrainPath = @"d:\Data\Terrain\filegdb_Containing_A_Terrain.gdb";
    var terrainURI = new Uri(terrainPath);
    
    var terrainCP = new TerrainLayerCreationParams(terrainURI);
    terrainCP.Name = "My Terrain Layer";
    terrainCP.IsVisible = false;
    
    //Create the layer to the terrain
    var terrainLayer = LayerFactory.Instance.CreateLayer<TerrainLayer>(terrainCP, map);
    
    Create a TerrainLayer from a dataset
    //Must be on the QueuedTask.Run()
    
    var terrainCP_ds = new TerrainLayerCreationParams(terrain);
    terrainCP_ds.Name = "My Terrain Layer";
    terrainCP_ds.IsVisible = true;
    
    //Create the layer to the terrain
    var terrainLayer_ds = LayerFactory.Instance.CreateLayer<TerrainLayer>(terrainCP_ds, map);
    Create a TerrainLayer with renderers
    //Must be on the QueuedTask.Run()
    
    var terrainCP_renderers = new TerrainLayerCreationParams(terrain);
    terrainCP_renderers.Name = "My LAS Layer";
    terrainCP_renderers.IsVisible = true;
    
    // define the edge type renderer - use defaults
    var edgeRD = new TinBreaklineRendererDefinition();
    
    // define the face/surface renderer
    var faceRD = new TinFaceClassBreaksRendererDefinition();
    faceRD.ClassificationMethod = ClassificationMethod.NaturalBreaks;
    // accept default color ramp, breakCount
    
    // define the dirty area renderer - use defaults
    var dirtyAreaRD = new TerrainDirtyAreaRendererDefinition();
    
    // add renderers to dictionary
    var t_dict = new Dictionary<SurfaceRendererTarget, TinRendererDefinition>();
    t_dict.Add(SurfaceRendererTarget.Edges, edgeRD);
    t_dict.Add(SurfaceRendererTarget.Surface, faceRD);
    t_dict.Add(SurfaceRendererTarget.DirtyArea, dirtyAreaRD);
    
    // assign dictionary to creation params
    terrainCP_renderers.RendererDefinitions = t_dict;
    
    //Create the layer to the terrain
    var terrainLayer_rd = LayerFactory.Instance.CreateLayer<TerrainLayer>(terrainCP_renderers, map);
    Dirty Area Renderer
    // applies to Terrain layers only
    
    var dirtyAreaRendererDef = new TerrainDirtyAreaRendererDefinition();
    // accept default labels, symbolTemplate
    
    var terrainLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<TerrainLayer>().FirstOrDefault();
    if (terrainLayer == null)
      return;
    
    if (terrainLayer.CanCreateRenderer(dirtyAreaRendererDef))
    {
      CIMTinRenderer renderer = terrainLayer.CreateRenderer(dirtyAreaRendererDef);
      if (terrainLayer.CanSetRenderer(renderer, SurfaceRendererTarget.DirtyArea))
        terrainLayer.SetRenderer(renderer, SurfaceRendererTarget.DirtyArea);
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Mapping.MapMember
             ArcGIS.Desktop.Mapping.Layer
                ArcGIS.Desktop.Mapping.SurfaceLayer
                   ArcGIS.Desktop.Mapping.TerrainLayer

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.2 or higher.
    See Also