This document is archived and information here might be outdated.  Recommended version.


How to save a function raster dataset into a raster dataset (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Processing raster data > Function raster datasets and raster functions > How to save a function raster dataset into a raster dataset

How to save a function raster dataset into a raster dataset


Saving a function raster dataset into a raster dataset

A function raster dataset when saved to a file (.afr) defines the processing to be performed on a dataset with a location for the dataset. It does not change the pixels of the original dataset. This topic shows how to save a function raster dataset into a raster dataset so that the processing performed on the base dataset is permanent.
Do the following steps to save a function raster dataset into a raster dataset:
  1. Create a raster workspace factory.
  2. Open the workspace pointing to the input folder.
  3. Open the .afr file as a raster dataset.
  4. Open the output workspace pointing to the output folder.
  5. Use the SaveAs function in the ISaveAs interface to save the input function raster to an output raster dataset with the output format.

    See the following code example:
[C#]
// Create a raster workspace factory.
IWorkspaceFactory workspaceFactory=new RasterWorkspaceFactory();
// Open the workspace pointing to the input folder.
IWorkspace workspace=workspaceFactory.OpenFromFile(@"c:\FRDs", 0);
IRasterWorkspace rasterWorkspace=(IRasterWorkspace)workspace;
// Open the .afr file as a raster dataset.
IRasterDataset myRasterDataset=rasterWorkspace.OpenRasterDataset(
    "CompositeBand.afr");
// Open the output workspace pointing to the output folder.
IWorkspace outputWorkspace=workspaceFactory.OpenFromFile(@"c:\temp", 0);
// Use the SaveAs interface to convert the raster dataset into an ISaveAs object.
ISaveAs saveAsRaster=(ISaveAs)myRasterDataset;
// Use the SaveAs function to save it to the output dataset with the output format.
saveAsRaster.SaveAs("outputFile.tif", outputWorkspace, "tiff");
[VB.NET]
' Create a raster workspace factory.
Dim workspaceFactory As IWorkspaceFactory=New RasterWorkspaceFactory()
' Open the workspace pointing to the input folder.
Dim workspace As IWorkspace=workspaceFactory.OpenFromFile("c:\FRDs", 0)
Dim rasterWorkspace As IRasterWorkspace=DirectCast(workspace, IRasterWorkspace)
' Open the .afr file as a raster dataset.
Dim myRasterDataset As IRasterDataset=rasterWorkspace.OpenRasterDataset("CompositeBand.afr")
' Open the output workspace pointing to the output folder.
Dim outputWorkspace As IWorkspace=workspaceFactory.OpenFromFile("c:\temp", 0)
' Use the SaveAs interface to convert the raster dataset into an ISaveAs object.
Dim saveAsRaster As ISaveAs=DirectCast(myRasterDataset, ISaveAs)
' Use the SaveAs function to save it to the output dataset with the output format.
saveAsRaster.SaveAs("outputFile.tif", outputWorkspace, "tiff")






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