How to export a raster dataset to a geodatabase and specify options


Summary
When exporting a raster dataset to another raster dataset in a geodatabase, a few options can be set according to the data and loading requirements. This article demonstrates the approach to specify different options when loading raster datasets to a geodatabase using the geoprocessing tool. Some of the options are applicable for exporting to a file-based raster dataset as well.

Exporting a raster dataset to a geodatabase and specifying options

The following code specifies the different options when loading raster datasets to a geodatabase using the geoprocessing tool:
[Java]
static void exportToGeodatabase()throws Exception{
    //    Use CopyRaster GP tool to load single raster dataset to GDB with options.
    //    Syntax: CopyRaster <in_raster> <out_rasterdataset> {config_keyword} {background_value} {nodata_value} {NONE | OneBitTo8Bit} {NONE | ColormapToRGB} 
    //    {1_BIT | 2_BIT | 4_BIT | 8_BIT_UNSIGNED | 8_BIT_SIGNED | 16_BIT_UNSIGNED | 16_BIT_SIGNED | 32_BIT_UNSIGNED | 32_BIT_SIGNED | 32_BIT_FLOAT | 64_BIT}
    //    Set parameters in the same order as the syntax shows, change any parameter to fit your data and loading requirement.
    IVariantArray parameters = new VarArray();
    //    Set in_raster.
    parameters.add("c:/tempdata/air-photo-1.tif");
    //    Set out_rasterdataset.
    parameters.add("Database Connections/Connection to qian.sde/RASTER.a_load");
    //    Set config_keyword to default.
    parameters.add("#");
    //    Set ignore background value to 0.
    parameters.add(0);
    //    Set NoData value to empty.
    parameters.add("#");
    //    Set onebitto8bit to NONE.
    parameters.add("NONE");
    //    Set colormaptoRGB to NONE.
    parameters.add("NONE");
    //    Set output pixel type as default.
    parameters.add("#");
    //    Set geoprocessor for execution.
    GeoProcessor geoprocessor = new GeoProcessor();
    geoprocessor.execute("CopyRaster", parameters, 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