Adding rasters to a Mosaic dataset
This topic shows how to add rasters to a Mosaic dataset. The Add Rasters operation requires a data crawler and a raster type. The data crawler is created in the function. Do the following steps to add rasters to a Mosaic dataset:
- Create a file crawler.
- Specify the source path.
- Specify whether to search subdirectories.
- Specify a file filter.
- Create an AddRastersParameters object.
- Specify the data crawler to use to crawl the data.
- Specify the raster type to use to add the data.
- Use the Mosaic dataset operation interface to add rasters to the Mosaic dataset.
See the following code example:
public void AddRastersToMD(IMosaicDataset theMosaicDataset, IRasterType
theRasterType)
{
// Create a file crawler.
IDataSourceCrawler myCrawler=new FileCrawlerClass();
// Specify the source path.
((IFileCrawler)myCrawler).Path=@"C:\TestData";
// Specify whether to search subdirectories.
((IFileCrawler)myCrawler).Recurse=true;
// Specify a file filter.
((IFileCrawler)myCrawler).Filters=".TIF";
// The mosaic dataset operation interface is used to perform operations on
// a mosaic dataset.
IMosaicDatasetOperation theMosaicDatasetOperation=(IMosaicDatasetOperation)
(theMosaicDataset);
// Create an AddRaster parameters object.
IAddRastersParameters AddRastersArgs=new AddRastersParametersClass();
// Specify the data crawler to use to crawl the data.
AddRastersArgs.Crawler=myCrawler;
// Specify the raster type to use to add the data.
AddRastersArgs.RasterType=theRasterType;
// Use the mosaic dataset operation interface to add
// rasters to the mosaic dataset.
theMosaicDatasetOperation.AddRasters(AddRastersArgs, null);
}
[VB.NET] Public Sub AddRastersToMD(ByVal theMosaicDataset As IMosaicDataset, ByVal theRasterType As IRasterType)
' Create a file crawler.
Dim theCrawler As IDataSourceCrawler=New FileCrawler()
Dim myFileCrawler As IFileCrawler=theCrawler
' Specify a file filter.
myFileCrawler.Filters=".TIF"
' Specify whether to search subdirectories.
myFileCrawler.Path="C:\TestData"
' Specify the source path.
myFileCrawler.Recurse=True
' The mosaic dataset operation interface is used to perform operations on
' a mosaic dataset.
Dim theMosaicDatasetOperation As IMosaicDatasetOperation =
DirectCast((theMosaicDataset), IMosaicDatasetOperation)
' Create an AddRaster parameters object.
Dim AddRastersArgs As IAddRastersParameters=New AddRastersParametersClass()
' Specify the data crawler to use to crawl the data.
AddRastersArgs.Crawler=theCrawler
' Specify the raster type to use to add the data.
AddRastersArgs.RasterType=theRasterType
' Use the mosaic dataset operation interface to add
' rasters to the mosaic dataset.
theMosaicDatasetOperation.AddRasters(AddRastersArgs, Nothing)
End Sub
See Also:
How to open a Mosaic datasetHow 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):
- ESRI.ArcGIS.DataSourcesRaster
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
- ESRI.ArcGIS.Geodatabase
Development licensing | Deployment licensing |
---|---|
ArcGIS Desktop Standard | ArcGIS Desktop Standard |
ArcGIS Desktop Advanced | ArcGIS Desktop Advanced |