ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / VoxelLayer Class
Members Example

In This Topic
    VoxelLayer Class
    In This Topic
    A voxel layer represents multidimensional spatial and temporal information in a 3D volumetric visualization.
    Object Model
    VoxelLayer ClassCIMDataConnection ClassCIMBaseLayer ClassCoordinate3D StructureSpatialReference ClassVoxelVariableProfile ClassMap ClassILayerContainer InterfaceEnvelope ClassVoxelVariableProfile ClassVoxelVolume Class
    Syntax
    Remarks
    Use voxel layers to visualize atmospheric or oceanic data, a geological underground model, or space-time cubes.
    Voxel layers are sourced from volumetric data stored using NetCDF.
    Voxel layers are supported in Local Scenes only. Refer to MapView.ViewingMode. Use of Voxel layers requires an Advanced licensing level
    Example
    Check if a Voxel Layer can be created
    //Map must be a local scene
    bool canCreateVoxel = (MapView.Active.ViewingMode == MapViewingMode.SceneLocal);
    
    if (canCreateVoxel)
    {
        //TODO - use the voxel api methods
    }
    Create Voxel Layer
    //Must be on the QueuedTask.Run()
    
    //Must be a .NetCDF file for voxels
    var url = @"C:\MyData\AirQuality_Redlands.nc";
    var cim_connection = new CIMVoxelDataConnection()
    {
        URI = url
    };
    //Create a VoxelLayerCreationParams
    var createParams = VoxelLayerCreationParams.Create(cim_connection);
    createParams.IsVisible = true;
    
    //Can also just use the path directly...
    //var createParams = VoxelLayerCreationParams.Create(url);
    
    //Use VoxelLayerCreationParams to enumerate the variables within
    //the voxel
    var variables = createParams.Variables;
    foreach (var variable in variables)
    {
        var line = $"{variable.Variable}: {variable.DataType}, " +
           $"{variable.Description}, {variable.IsDefault}, {variable.IsSelected}";
        System.Diagnostics.Debug.WriteLine(line);
    }
    //Optional: set the default variable
    createParams.SetDefaultVariable(variables.Last());
    
    //Create the layer - map must be a local scene
    VoxelLayer voxelLayer = LayerFactory.Instance.CreateLayer<VoxelLayer>(createParams, map);
    Get a Voxel Layer from the TOC
    //Get selected layer if a voxel layer is selected
    var voxelLayer = MapView.Active.GetSelectedLayers().OfType<VoxelLayer>().FirstOrDefault();
    if (voxelLayer == null)
    {
        //just get the first voxel layer in the TOC
        voxelLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<VoxelLayer>().FirstOrDefault();
        if (voxelLayer == null)
            return;
    }
    Manipulate the Voxel Layer TOC Group
    //var voxelLayer = ...
    //Must be on the QueuedTask.Run()
    
    //Toggle containers and visibility in the TOC
    voxelLayer.SetExpanded(!voxelLayer.IsExpanded);
    voxelLayer.SetVisibility(!voxelLayer.IsVisible);
    voxelLayer.SetIsosurfaceContainerExpanded(!voxelLayer.IsIsosurfaceContainerExpanded);
    voxelLayer.SetIsosurfaceContainerVisibility(!voxelLayer.IsIsosurfaceContainerVisible);
    voxelLayer.SetSliceContainerExpanded(voxelLayer.IsSliceContainerExpanded);
    voxelLayer.SetSliceContainerVisibility(!voxelLayer.IsSliceContainerVisible);
    voxelLayer.SetSectionContainerExpanded(!voxelLayer.IsSectionContainerExpanded);
    voxelLayer.SetSectionContainerVisibility(!voxelLayer.IsSectionContainerVisible);
    voxelLayer.SetLockedSectionContainerExpanded(!voxelLayer.IsLockedSectionContainerExpanded);
    voxelLayer.SetLockedSectionContainerVisibility(!voxelLayer.IsLockedSectionContainerVisible);
    
    Subscribe for Changes to a Voxel Layer
    ArcGIS.Desktop.Mapping.Events.MapMemberPropertiesChangedEvent.Subscribe((args) =>
    {
        var voxel = args.MapMembers.OfType<VoxelLayer>().FirstOrDefault();
        if (voxel == null)
            return;
        //Anything changed on a voxel layer?
        //At 2.x - if (args.EventHints.Any(hint => hint == MapMemberEventHint.VoxelSelectedVariableProfileIndex))
        if (args.EventHints.Any(hint => hint == MapMemberEventHint.VoxelSelectedVariable))
        {
            //Voxel variable profile selection changed
            var changed_variable_name = voxel.SelectedVariableProfile.Variable;
            //TODO respond to change, use QueuedTask if needed
    
        }
        else if (args.EventHints.Any(hint => hint == MapMemberEventHint.Renderer))
        {
            //This can fire when a renderer becomes ready on a new layer; the selected variable profile
            //is changed; visualization is changed, etc.
            var renderer = voxel.SelectedVariableProfile.Renderer;
            //TODO respond to change, use QueuedTask if needed
    
        }
    });
    
    ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetChangedEvent.Subscribe((args) =>
    {
        //An asset changed on a voxel layer
        System.Diagnostics.Debug.WriteLine("");
        System.Diagnostics.Debug.WriteLine("VoxelAssetChangedEvent");
        System.Diagnostics.Debug.WriteLine($" AssetType: {args.AssetType}, ChangeType: {args.ChangeType}");
    
        if (args.ChangeType == VoxelAssetEventArgs.VoxelAssetChangeType.Remove)
            return;
        //Get "what"changed - add or update
        //eg IsoSurface
        VoxelLayer voxelLayer = null;
        if (args.AssetType == VoxelAssetEventArgs.VoxelAssetType.Isosurface)
        {
            var surface = MapView.Active.GetSelectedIsosurfaces().FirstOrDefault();
            //there will only be one selected...
            if (surface != null)
            {
                voxelLayer = surface.Layer;
                //TODO respond to change, use QueuedTask if needed
            }
        }
        //Repeat for Slices, Sections, LockedSections...
        //GetSelectedSlices(), GetSelectedSections(), GetSelectedLockedSections();
    });
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Mapping.MapMember
             ArcGIS.Desktop.Mapping.Layer
                ArcGIS.Desktop.Mapping.VoxelLayer

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also