ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / VoxelLayerCreationParams Class / Create Method / Create(CIMVoxelDataConnection) Method
A valid CIMVoxelDataConnection
Example

In This Topic
    Create(CIMVoxelDataConnection) Method
    In This Topic
    Create a VoxelLayerCreationParams using the given CIMVoxelDataConnection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    dataConnection
    A valid CIMVoxelDataConnection

    Return Value

    Exceptions
    ExceptionDescription
    Thrown when a method is called on the wrong Pro thread
    dataConnection is null
    'dataConnection URI' does not exist
    'dataConnection URI' must be a NetCDF file (.nc)
    Remarks
    Valid datasources for voxel layers are:
    - NetCDF (.nc) data files
    Voxel layers can only be added to local scenes. If a voxel layer is added to a global scene the layer will not draw. If a voxel layer is added to a 2D map or stereo map a System.InvalidOperationException is thrown when calling LayerFactory.CreateLayer<T>
    If adding to a group layer, it must be SceneLayerType.SceneLayer3D or a System.InvalidOperationException is thrown when calling LayerFactory.CreateLayer<T>
    Example
    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);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also