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


How to create a Mosaic dataset (ArcObjects .NET 10.4 SDK)

How to create a Mosaic dataset


Creating a Mosaic dataset

Do the following steps to create a Mosaic dataset:
  1. Create a geodatabase workspace factory.
  2. Open the geodatabase.
  3. Create a spatial reference.
  4. Create the Mosaic dataset creation parameters object.
  5. Set the number of bands for the Mosaic dataset.
  6. Set the Mosaic dataset pixel type.
  7. Create the Mosaic workspace extension helper class.
  8. Find the correct extension from the workspace.
  9. Use the extension to create a Mosaic dataset with the spatial reference and the creation parameters.

    See the following code example:
[C#]
// Create a gdb workspace factory.
IWorkspaceFactory workspaceFactory=new FileGDBWorkspaceFactory();
// Open the gdb.
IWorkspace fgdbWorkspace=workspaceFactory.OpenFromFile(@"C:\testGdb.gdb", 0);

// Create Srs.
ISpatialReferenceFactory spatialrefFactory=new SpatialReferenceEnvironmentClass();
ISpatialReference mosaicSrs=spatialrefFactory.CreateProjectedCoordinateSystem((int)
    (esriSRProjCSType.esriSRProjCS_World_Mercator));

// Create the mosaic dataset creation parameters object.
ICreateMosaicDatasetParameters creationPars=new CreateMosaicDatasetParametersClass
    ();
// Set the number of bands for the mosaic dataset.
creationPars.BandCount=3;
// Set the pixel type of the mosaic dataset.
creationPars.PixelType=rstPixelType.PT_UCHAR;
// Create the mosaic workspace extension helper class.
IMosaicWorkspaceExtensionHelper mosaicExtHelper=new
    MosaicWorkspaceExtensionHelperClass();
// Find the right extension from the workspace.
IMosaicWorkspaceExtension mosaicExt=mosaicExtHelper.FindExtension(fgdbWorkspace);
// Use the extension to create a mosaic dataset, supplying the 
// spatial reference and the creation parameters object previously created.
IMosaicDataset theMosaicDataset=mosaicExt.CreateMosaicDataset("testMD", mosaicSrs,
    creationPars);
[VB.NET]
' Create a gdb workspace factory.
Dim workspaceFactory As IWorkspaceFactory=New FileGDBWorkspaceFactory()
' Open the gdb.
Dim fgdbWorkspace As IWorkspace=workspaceFactory.OpenFromFile("C:\testGdb.gdb", 0)

' Create Srs.
Dim spatialrefFactory As ISpatialReferenceFactory=New SpatialReferenceEnvironmentClass()
Dim mosaicSrs As ISpatialReference=spatialrefFactory.CreateProjectedCoordinateSystem(CInt((esriSRProjCSType.esriSRProjCS_World_Mercator)))

' Create the mosaic dataset creation parameters object.
Dim creationPars As ICreateMosaicDatasetParameters=New CreateMosaicDatasetParametersClass()
' Set the number of bands for the mosaic dataset.
creationPars.BandCount=3
' Set the pixel type of the mosaic dataset.
creationPars.PixelType=rstPixelType.PT_UCHAR
' Create the mosaic workspace extension helper class.
Dim mosaicExtHelper As IMosaicWorkspaceExtensionHelper=New MosaicWorkspaceExtensionHelperClass()
' Find the right extension from the workspace.
Dim mosaicExt As IMosaicWorkspaceExtension=mosaicExtHelper.FindExtension(fgdbWorkspace)
' Use the extension to create a mosaic dataset, supplying the
' spatial reference and the creation parameters object previously created.
Dim theMosaicDataset As IMosaicDataset=mosaicExt.CreateMosaicDataset("testMD", mosaicSrs, creationPars)






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