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


How to open and prepare a raster type (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 open and prepare a raster type (ArcObjects .NET 10.6 SDK)

How to open and prepare a raster type


Opening and preparing a raster type

This topic shows how to open and prepare a raster type. A raster type consists of two main parameters that control how the raster type is used to add data—the uniform resource identifier (URI) filter and the item template. The URI filter determines the type of data to add (for example, if adding QuickBird data, setting the URI filter to "Basic" only adds the QuickBird Basic data). The item template determines what processing to perform on the added data.
Do the following steps to open and prepare a raster type:
  1. Create a raster type name object.
  2. Assign the name of the raster type to the name object. The Name field accepts a path to an .art file as well as the name for a built-in raster type.
  3. Use the Open function from the IName interface to get the raster type object.
  4. Set the URI filter on the loaded raster type.
    1. Get the supported URI filters from the raster type object using the raster type properties interface.
    2. Set the applicable filter from the supported filters.
  5. Enable the correct templates in the raster type.
    1. Get the supported item templates from the raster type.
    2. Go through the supported item templates and enable the applicable templates.
See the following code example:
[C#]
// Create a raster type name object.
IRasterTypeName theRasterTypeName=new RasterTypeNameClass();
// Assign the name of the raster type to the name object.
// The Name field accepts a path to an .art file as well as
// the name for a built-in raster type.
theRasterTypeName.Name="QuickBird";
// Use the Open function from the IName interface to get the raster type object.
IRasterType theRasterType=(IRasterType)(((IName)theRasterTypeName).Open());
if (theRasterType == null)
    Console.WriteLine("Raster Type not found: QuickBird");
// Set the URI filter on the loaded raster type.
// Get the supported URI filters from the raster type object using the 
// raster type properties interface.
IArray mySuppFilters=((IRasterTypeProperties)theRasterType).SupportedURIFilters;
IItemURIFilter productFilter=null;
for (int i=0; i < mySuppFilters.Count; ++i)
{
    // Set the desired filter from the supported filters.
    productFilter=(IItemURIFilter)mySuppFilters.get_Element(i);
    if (productFilter.Name == "Basic")
        theRasterType.URIFilter=productFilter;
}

// Enable the correct templates in the raster type.
// Get the supported item templates from the raster type.
IItemTemplateArray templateArray=theRasterType.ItemTemplates;
for (int i=0; i < templateArray.Count; ++i)
{
    // Go through the supported item templates and enable the applicable templates.
    IItemTemplate template=templateArray.get_Element(i);
    if (template.Name == "Pansharpen" || template.Name == "Multispectral")
        template.Enabled=true;
    else
        template.Enabled=false;
}
[VB.NET]
' Create a raster type name object.
Dim theRasterTypeName As IRasterTypeName
theRasterTypeName=New RasterTypeName()
' Assign the name of the raster type to the name object.
' The Name field accepts a path to an .art file as well as
' the name for a built-in raster type.
theRasterTypeName.NameString="QuickBird"
' Use the Open function from the IName interface to get the raster type object.
Dim theRasterTypeIName As IName=theRasterTypeName
Dim theRasterType As IRasterType
theRasterType=theRasterTypeIName.Open()
If (theRasterType Is Nothing) Then
    Console.WriteLine("Raster Type not found " + "QuickBird")
End If
' Set the URI filter on the loaded raster type.
' Get the supported URI filters from the raster type object using the
' raster type properties interface.
Dim mySuppFilters As IArray=pRasterProp.SupportedURIFilters
If (String.Compare(rasterTypeProductFilter, String.Empty) > 0) Then
    Dim productFilter As IItemURIFilter=Nothing
    Dim i As Integer
    Dim pItemURIFilter As IItemURIFilter
    For i=0 To i < mySuppFilters.Count
        ' Set the desired filter from the supported filters.
        productFilter=mySuppFilters.Element(i)
        If (productFilter.Name="Basic") Then
            theRasterType.URIFilter=productFilter
        End If
    Next
End If
' Enable the correct templates in the raster type.
' Get the supported item templates from the raster type.
Dim templateArray As IItemTemplateArray=theRasterType.ItemTemplates
Dim i, j As Integer
For i=0 To templateArray.Count
    ' Go through the supported item templates and enable the applicable templates.
    Dim template As IItemTemplate=templateArray.Element(i)
    If (template.Name="Pansharpen" Or template.Name="Multispectral") Then
        template.Enabled=True
    Else
        template.Enabled=False
    End If
Next






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