I have the following code opening up the mosaic dataset which appears to work just fine. However, I have no idea how to access the rasters contained within the dataset. All I really care about doing is making a PixelBlock from the raster(s) so that I can read the pixel values. There are loads of example of how to create a mosaic dataset from individual rasters, but I cannot find a single one that talks about how to read rasters from a mosaic dataset.
IRasterDataset makes this somewhat simple using CreateDefaultRaster(), but I've found no such path to getting at the raster data within a mosaic dataset.
IMosaicWorkspaceExtensionHelperPtr mosaic_ext_helper(CLSID_MosaicWorkspaceExtensionHelper);
IMosaicWorkspaceExtensionPtr mosaic_ext;
mosaic_ext_helper->FindExtension(_workspace, &mosaic_ext);
IMosaicDatasetPtr mosaic_dataset;
mosaic_ext->OpenMosaicDataset(_bstr_t(ds_name.c_str()), &mosaic_dataset));
// Somehow(???) get the rasters (or their pixel data) from mosaic_dataset
[SOLUTION]
This is what I came up with as a solution. It may not be ideal, but it works to get at the pixels in the rasters.
IMosaicWorkspaceExtensionHelperPtr mosaic_ext_helper(CLSID_MosaicWorkspaceExtensionHelper);
IMosaicWorkspaceExtensionPtr mosaic_ext;
mosaic_ext_helper->FindExtension(_workspace, &mosaic_ext);
IMosaicDatasetPtr mosaic_dataset;
if (FAILED(mosaic_ext->OpenMosaicDataset(mosaic_dataset_name, &mosaic_dataset)))
{
// Error here
}
IFeatureClassPtr feature_class;
mosaic_dataset->get_Catalog(&feature_class);
IQueryFilterPtr query_filter(CLSID_QueryFilter);
IFeatureCursorPtr feature_cursor;
if (FAILED(feature_class->Search(query_filter, VARIANT_FALSE, &feature_cursor)))
{
// Error here
}
IFeaturePtr feature;
while (feature_cursor->NextFeature(&feature) == S_OK)
{
esriFeatureType type; // Returns esriFTRasterCatalogItem
feature->get_FeatureType(&type);
IRasterCatalogItemPtr catalog_item(feature);
IRasterDatasetPtr raster_dataset;
catalog_item->get_RasterDataset(&raster_dataset);
IRasterPtr raster;
raster_dataset->CreateDefaultRaster(&raster);
// Do something with the each Raster or RasterDataset
}