Saving a raster type to a .art file
Do the following steps to save a raster type to a .art file:
- Use the IRasterTypeProperties interface to give the saved raster type a name.
- 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:
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 typeTo 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):
- ESRI.ArcGIS.DataSourcesRaster
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
Development licensing | Deployment licensing |
---|---|
ArcGIS Desktop Standard | ArcGIS Desktop Standard |
ArcGIS Desktop Advanced | ArcGIS Desktop Advanced |