Saving as raster data
By using the ISaveAs interface, you can save a raster dataset or a raster into many raster formats. You can also save to a geodatabase if the output workspace is one of the geodatabase workspaces. See the following code example:
[Java]
static void saveAsWithCompressionAndTile(IRasterDataset rasterDataset)throws
Exception{
//pRasterDataset can be created from any data source, file system, or geodatabase. It could also be a raster object (IRaster).
ISaveAs2 saveAs2 = new ISaveAs2Proxy(rasterDataset);
//Set storage.
RasterStorageDef definition = new RasterStorageDef();
definition.setCompressionType
(esriRasterCompressionType.esriRasterCompressionJPEG2000);
definition.setCompressionQuality(50);
definition.setTileHeight(128);
definition.setTileWidth(128);
//Set output workspace.
IWorkspace workspace = openFileGDBWorkspace("c:\\temp\\fgdb.gdb");
saveAs2.saveAsRasterDataset("filegdbRaster", workspace, "gdb", definition);
}
static IWorkspace openFileGDBWorkspace(String path)throws Exception{
FileGDBWorkspaceFactory factory = new FileGDBWorkspaceFactory();
return factory.openFromFile(path, 0);
}
Turning off pyramid building
You can also turn off pyramid building for outputs, such as IMG, GRID, and TIFF formats using the ISaveAs2 interface. See the following code example:
static void saveAsWithoutBuildingPyramids(IRaster raster)throws Exception{
ISaveAs2 pSaveAs2 = new ISaveAs2Proxy(raster);
RasterStorageDef definition = new RasterStorageDef();
definition.setPyramidLevel(0);
IWorkspace workspace = setRasterWorkspace("c:\\temp");
pSaveAs2.saveAsRasterDataset("image1.img", workspace, "IMAGINE Image",
definition);
}
static IWorkspace setRasterWorkspace(String path)throws Exception{
RasterWorkspaceFactory factory = new RasterWorkspaceFactory();
return factory.openFromFile(path, 0);
}
Development licensing | Deployment licensing |
---|---|
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime |