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


How to create a referenced mosaic dataset (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 create a referenced mosaic dataset (ArcObjects .NET 10.6 SDK)

How to create a referenced mosaic dataset


Summary
A referenced mosaic dataset references an external raster catalog or an external mosaic dataset. There are basically two cases when you might need to create a referenced mosaic dataset: 1) You have an existing raster catalog, and you want to make it available to ArcGIS Server. In this case, you can create a referenced mosaic dataset from the raster catalog, and publish it using ArcGIS Server; and 2) You have an existing mosaic dataset, and you need multiple views of the mosaic. In this case, you can create referenced mosaic datasets from the existing mosaic dataset by specifying a definition query or an extent.
This topic shows how to create a referenced mosaic dataset using the ArcObjects application programming interface (API). A referenced mosaic dataset can also be created using the Create Referenced Mosaic Dataset geoprocessing tool.

In this topic


Creating a referenced mosaic dataset from a raster catalog

To create a referenced mosaic dataset from a raster catalog, follow these steps:
  1. Create a MosaicWorkspaceExtension object.
  2. Use the IMosaicWorkspaceExtension.CreateReferencedMosaicDataset method to create the referenced mosaic dataset.
  3. Use MaximumVisibleCellsize for the mosaic parameter.
See the following code example:
[C#]
static void CreateReferencedMosaic(IWorkspace ws, String MosaicDatasetName,
    ISpatialReference SR, IRasterCatalog catalog)
{
    //Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension 
    //class from a workspace (ws).
    IMosaicWorkspaceExtensionHelper MosaicWsHelper=new
        MosaicWorkspaceExtensionHelperClass();
    IMosaicWorkspaceExtension mosaicWsExtension=MosaicWsHelper.FindExtension(ws);

    //Define the parameters for creating a referenced mosaic dataset.
    ICreateMosaicDatasetParameters mdParameters=new
        CreateMosaicDatasetParametersClass();
    mdParameters.BandCount=3; //Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR; //Optional.

    //If the raster catalog is a regular raster catalog, define this parameter.
    mdParameters.MaximumVisibleCellsize=10; 
        //This is the threshold above which a rasterized wireframe will be displayed.

    //Create the referenced mosaic dataset. 
    //Name represents the name of the mosaic dataset, SR represents the spatial reference, 
    //and catalog can be the input raster catalog or mosaic dataset.
    IMosaicDataset md=mosaicWsExtension.CreateReferencedMosaicDataset
        (MosaicDatasetName, SR, catalog, null, mdParameters);
}
[VB.NET]
Public Sub CreateReferencedMoaic(ByVal ws As IWorkspace, ByVal MosaicDatasetName As String, ByVal catalog As IRasterCatalog, ByVal SR As ISpatialReference)
    'Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension class
    'from a workspace (ws).
    Dim MosaicWsHelper As IMosaicWorkspaceExtensionHelper
    MosaicWsHelper=New MosaicWorkspaceExtensionHelperClass()
    Dim mosaicWsExtension As IMosaicWorkspaceExtension
    mosaicWsExtension=MosaicWsHelper.FindExtension(ws)
    
    'Define the parameters for creating a referenced mosaic dataset.
    Dim mdParameters As ICreateMosaicDatasetParameters
    mdParameters=New CreateMosaicDatasetParametersClass()
    mdParameters.BandCount=3 'Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR 'Optional.
    
    'If the raster catalog is a regular raster catalog, define this parameter.
    mdParameters.MaximumVisibleCellsize=10
    'This is the threshold above which a rasterized wireframe will be displayed.
    
    'Create the referenced mosaic dataset.
    'Name represents the name of the mosaic dataset, SR represents the spatial reference,
    'and catalog can be the input raster catalog or mosaic dataset.
    Dim md As IMosaicDataset=mosaicWsExtension.CreateReferencedMosaicDataset(MosaicDatasetName, SR, catalog, Nothing, mdParameters)
End Sub

Creating a referenced mosaic dataset from a Military Analyst raster catalog

To create a referenced mosaic dataset from a Military Analyst raster catalog, follow these steps:
  1. Create a MosaicWorkspaceExtension object.
  2. Use the IMosaicWorkspaceExtension.CreateReferencedMosaicDataset method to create the referenced mosaic dataset.
  3. Use LODFieldName for the mosaic parameter.
See the following code example, which defines the visibility using the Scale field in the raster catalog:
[C#]
static void CreateReferencedMosaic(IWorkspace ws, String MosaicDatasetName,
    ISpatialReference SR, IRasterCatalog catalog)
{
    //Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension 
    //class from a workspace (ws).
    IMosaicWorkspaceExtensionHelper MosaicWsHelper=new
        MosaicWorkspaceExtensionHelperClass();
    IMosaicWorkspaceExtension mosaicWsExtension=MosaicWsHelper.FindExtension(ws);

    //Define the parameters for creating a referenced mosaic dataset.
    ICreateMosaicDatasetParameters mdParameters=new
        CreateMosaicDatasetParametersClass();
    mdParameters.BandCount=3; //Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR; //Optional.

    //If the raster catalog is a regular raster catalog, define this parameter.
    mdParameters.LODFieldName="Scale"; 
        //This is the threshold above which a rasterized wireframe will be displayed.

    //Create the referenced mosaic dataset. 
    //Name represents the name of the mosaic dataset, SR represents the spatial reference, 
    //and catalog can be the input raster catalog or mosaic dataset.
    IMosaicDataset md=mosaicWsExtension.CreateReferencedMosaicDataset
        (MosaicDatasetName, SR, catalog, null, mdParameters);
}
[VB.NET]
Public Sub CreateReferencedMoaic(ByVal ws As IWorkspace, ByVal MosaicDatasetName As String, ByVal catalog As IRasterCatalog, ByVal SR As ISpatialReference)
    'Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension class
    'from a workspace (ws).
    Dim MosaicWsHelper As IMosaicWorkspaceExtensionHelper
    MosaicWsHelper=New MosaicWorkspaceExtensionHelperClass()
    Dim mosaicWsExtension As IMosaicWorkspaceExtension
    mosaicWsExtension=MosaicWsHelper.FindExtension(ws)
    
    'Define the parameters for creating a referenced mosaic dataset.
    Dim mdParameters As ICreateMosaicDatasetParameters
    mdParameters=New CreateMosaicDatasetParametersClass()
    mdParameters.BandCount=3 'Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR 'Optional.
    
    'If the raster catalog is a regular raster catalog, define this parameter.
    mdParameters.LODFieldName="Scale"
    
    'Create the referenced mosaic dataset.
    'Name represents the name of the mosaic dataset, SR represents the spatial reference,
    'and catalog can be the input raster catalog or mosaic dataset.
    Dim md As IMosaicDataset=mosaicWsExtension.CreateReferencedMosaicDataset(MosaicDatasetName, SR, catalog, Nothing, mdParameters)
End Sub

Creating a referenced mosaic dataset from an existing mosaic dataset

To create a referenced mosaic dataset from an existing mosaic dataset, follow these steps:
  1. Create a MosaicWorkspaceExtension object.
  2. Use the IMosaicWorkspaceExtension.CreateReferencedMosaicDataset method to create the referenced mosaic dataset.
  3. Use MinCellsizeFieldName and MaxCellsizeFieldName for the mosaic parameter.
See the following code example, which defines the visibility parameters from the MinPS and MaxPS fields:
[C#]
static void CreateReferencedMosaic(IWorkspace ws, String MosaicDatasetName,
    ISpatialReference SR, IRasterCatalog catalog)
{
    //Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension 
    //class from a workspace (ws).
    IMosaicWorkspaceExtensionHelper MosaicWsHelper=new
        MosaicWorkspaceExtensionHelperClass();
    IMosaicWorkspaceExtension mosaicWsExtension=MosaicWsHelper.FindExtension(ws);

    //Define the parameters for creating a referenced mosaic dataset.
    ICreateMosaicDatasetParameters mdParameters=new
        CreateMosaicDatasetParametersClass();
    mdParameters.BandCount=3; //Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR; //Optional.

    //If the raster catalog is a regular raster catalog, define this parameter.

    mdParameters.MinCellsizeFieldName="MinPS";
    mdParameters.MaxCellsizeFieldName="MaxPS";

    //Create the referenced mosaic dataset. 
    //Name represents the name of the mosaic dataset, SR represents the spatial reference, 
    //and catalog can be the input raster catalog or mosaic dataset.
    IMosaicDataset md=mosaicWsExtension.CreateReferencedMosaicDataset
        (MosaicDatasetName, SR, catalog, null, mdParameters);
}
[VB.NET]
Public Sub CreateReferencedMoaic(ByVal ws As IWorkspace, ByVal MosaicDatasetName As String, ByVal catalog As IRasterCatalog, ByVal SR As ISpatialReference)
    'Use the IMosaicWorkspaceExtensionHelper class to obtain a MosaicWorkspaceExtension class
    'from a workspace (ws).
    Dim MosaicWsHelper As IMosaicWorkspaceExtensionHelper
    MosaicWsHelper=New MosaicWorkspaceExtensionHelperClass()
    Dim mosaicWsExtension As IMosaicWorkspaceExtension
    mosaicWsExtension=MosaicWsHelper.FindExtension(ws)
    
    'Define the parameters for creating a referenced mosaic dataset.
    Dim mdParameters As ICreateMosaicDatasetParameters
    mdParameters=New CreateMosaicDatasetParametersClass()
    mdParameters.BandCount=3 'Optional.
    mdParameters.PixelType=rstPixelType.PT_UCHAR 'Optional.
    
    'If the raster catalog is a regular raster catalog, define this parameter.
    
    mdParameters.MinCellsizeFieldName="MinPS"
    mdParameters.MaxCellsizeFieldName="MaxPS"
    
    'Create the referenced mosaic dataset.
    'Name represents the name of the mosaic dataset, SR represents the spatial reference,
    'and catalog can be the input raster catalog or mosaic dataset.
    Dim md As IMosaicDataset=mosaicWsExtension.CreateReferencedMosaicDataset(MosaicDatasetName, SR, catalog, Nothing, mdParameters)
End Sub






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