How to load a raster dataset to a raster attribute column in a feature class

Loading a raster dataset to a raster attribute column in a feature class

A feature class or table can have a raster attribute field to store any raster related to the feature. This article shows how to load a raster dataset into a feature in a feature class given the ObjectID (OID) of the feature. Only geodatabase feature classes can have a raster attribute field. See the following code example:
static void loadToRasterAttribute(IFeatureClass featureClass, IRasterDataset
    rasterDataset, int OID)throws Exception{
    featureClass: the feature class with raster attribute
    rasterDataset: the raster dataset to be loaded to the raster attribute
    OID: the objectid of the feature to be edited

    //Get workspace for editing
    IDataset dataset = (IDataset)featureClass;
    IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dataset.getWorkspace();
    IFeature feature = featureClass.getFeature(OID);

    //Find raster field index
    int iRasterField = 0;
    for (int i = 0; i < feature.getFields().getFieldCount(); i++){
        if (feature.getFields().getField(i).getType() ==
            iRasterField = i;
            i = 1000;

    //Create raster value with input raster dataset
    IRasterValue rasterValue = new RasterValue();

    //Set raster value to the raster field
    feature.setValue(iRasterField, rasterValue);;

    //Stop editing and save edits

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