ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SpatialIndexDescription Class / SpatialIndexDescription Constructor / SpatialIndexDescription Constructor(FeatureClassDescription)
The description object representing the ArcGIS.Core.Data.FeatureClass that will hold the index.
Example Version

SpatialIndexDescription Constructor(FeatureClassDescription)
Creates a description object of the spatial ArcGIS.Core.Data.Index.
Syntax

Parameters

featureClassDescription
The description object representing the ArcGIS.Core.Data.FeatureClass that will hold the index.
Exceptions
ExceptionDescription
featureClassDescription cannot be null
Remarks
Creates a spatial index description with a pre-set name.
Example
Adding indexes in pre-existing dataset
public void AddingIndexes(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition)
{
    // Field names to add in the attribute index
    string fieldName = featureClassDefinition.GetFields().First(f => f.AliasName.Contains("Name")).Name;
    string fieldAddress = featureClassDefinition.GetFields().First(f => f.AliasName.Contains("Address")).Name;

    // Creating an attribute index with index name 'Idx' and two participating fields' name
    AttributeIndexDescription attributeIndexDescription = new AttributeIndexDescription("Idx", new TableDescription(featureClassDefinition), new List<string> { fieldName, fieldAddress });

    // Enqueue DDL operation for an attribute index creation 
    schemaBuilder.Create(attributeIndexDescription);

    // Creating the spatial index 
    SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));

    // Enqueue DDL operation for the spatial index creation
    schemaBuilder.Create(spatialIndexDescription);

    // Execute build indexes operation
    bool isBuildSuccess = schemaBuilder.Build();

    if (!isBuildSuccess)
    {
        IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        // Iterate and handle errors 
    }
}
Removing spatial index
public void RemoveSpatialIndex(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition)
{
    // Create a spatial description  
    SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));

    // Enqueue the DDL operation to remove index 
    schemaBuilder.Delete(spatialIndexDescription);

    // Execute the delete index operation
    bool isDeleteIndexSuccess = schemaBuilder.Build();
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.4 or higher.
See Also