How to save a raster type to a .art file (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Working with Mosaic datasets > How to save a raster type to a .art file (ArcObjects .NET 10.6 SDK)

How to save a raster type to a .art file


Saving a raster type to a .art file

Do the following steps to save a raster type to a .art file:
  1. Use the IRasterTypeProperties interface to give the saved raster type a name.
  2. Use the raster type environment class to save the raster type. The saved raster type is given out as a memory blob that is written to the file.

    See the following code example:
[C#]
public void SaveRasterType(IRasterType theRasterType, string rasterTypeFilePath)
{
    // The raster type properties interface can be used to give the saved raster type a name.
    IRasterTypeProperties theRasterTypeProperties=(IRasterTypeProperties)
        theRasterType;
    theRasterTypeProperties.Name="myRasterType";
    // The raster type environment class is used to save the raster type.
    IRasterTypeEnvironment theRasterTypeEnv=new RasterTypeEnvironmentClass();
    // The saved raster type is given out as a memory blob,
    IMemoryBlobStream ipBlob=theRasterTypeEnv.SaveRasterType(theRasterType);
    // which is then written out to the file.
    ipBlob.SaveToFile(rasterTypeFilePath);
    Console.WriteLine("Successfully saved: " + rasterTypeFilePath);
}
[VB.NET]
Public Sub SaveRasterType(ByVal theRasterType As IRasterType, ByVal rasterTypeFilePath As String)
    ' The raster type properties interface can be used to give the saved raster type a name.
    Dim theRasterTypeProperties As IRasterTypeProperties=DirectCast(theRasterType, IRasterTypeProperties)
    theRasterTypeProperties.Name="myRasterType"
    ' The raster type environment class is used to save the raster type.
    Dim theRasterTypeEnv As IRasterTypeEnvironment=New RasterTypeEnvironmentClass()
    ' The saved raster type is given out as a memory blob,
    Dim ipBlob As IMemoryBlobStream=theRasterTypeEnv.SaveRasterType(theRasterType)
    ' which is then written out to the file.
    ipBlob.SaveToFile(rasterTypeFilePath)
    Console.WriteLine("Successfully saved: " & rasterTypeFilePath)
End Sub


See Also:

How to open and prepare a raster type




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 Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced