How to set options when exporting a raster dataset to a geodatabase (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Accessing raster datasets > How to set options when exporting a raster dataset to a geodatabase (ArcObjects .NET 10.6 SDK)

How to set options when exporting a raster dataset to a geodatabase


Summary
When exporting a raster dataset to another raster dataset in a geodatabase, various options can be set depending on the data and loading requirements. This topic shows how to specify options when loading raster datasets to a geodatabase using the Copy Raster geoprocessing tool. Some of the options are applicable to exporting to a file-based raster dataset as well.

Setting options when exporting a raster dataset to a geodatabase

The following code shows the available options when loading a raster dataset to a geodatabase using the Copy Raster geoprocessing tool:
To connect to an ArcSDE geodatabase as shown in this code, an ArcGIS Desktop Standard or Advanced license is required.
[C#]
//Use the Copy Raster GP tool to load a single raster dataset to a 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 requirements.
IVariantArray parameters=new VarArrayClass();
//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);
[VB.NET]
'Use the Copy Raster GP tool to load a single raster dataset to a 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 requirements.
Dim parameters As IVariantArray=New VarArrayClass()
'Set in_raster.
parameters.Add("c:\tempdata\air-photo-1.tif")
'Set out_rasterdataset.
parameters.Add("Database Connections\Connection to qian.sde\RASTER.a1_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.
Dim geoprocessor As Geoprocessor=New Geoprocessor()
geoprocessor.Execute("CopyRaster", parameters, Nothing)






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine