How to access a layer's underlying data


Accessing a layer's underlying data

Layers are often an entry point to accessing data. While there are some special layer types with specific methods to access data, the common layer types implement the interfaces IFeatureLayer and IDisplayTable. IFeatureLayer provides access to the base FeatureClass that the layer is based on, while IDisplayTable provides access to the DisplayTable, which may include joined tables, and so on. The following example shows how to access the FeatureClass via IFeatureLayer:
[Java]
static IFeatureClass accessLayersData(ILayer layer)throws Exception{
    IFeatureLayer featureLayer = (IFeatureLayer)layer;
    if (featureLayer != null)
        return featureLayer.getFeatureClass();
    else
        return null;

}
The next example demonstrates how to access the DisplayTable by using the IDisplayTable interface. Note that IDisplayTable also includes methods for querying and selecting features. Use these methods to ensure proper behavior when dealing with joined data. See the following:
[Java]
static ITable accessLayersDisplayTable(ILayer layer)throws Exception{
    IDisplayTable displayTable = (IDisplayTable)layer;
    if (displayTable != null)
        return displayTable.getDisplayTable();
    else
        return null;

}






Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine