How do I get a raster from the IGdbRasterCatalogLayer interface?

340
1
06-12-2012 08:14 PM
AllanMills
New Contributor III
I've got a pair of raster catalogs sitting in a GDB. I want to extract the rasters individually and cast/wrap them into an IRasterLayer object so I can query them.

The problem is, I'm stumped on how to do this. The IRasterCatalogLayer interface would seem to be perfect for this kind of thing, but it is for RasterCatalogLayer class objects. The data I have seems to be GdbRasterCatalogLayer class objects which has a different interface. Specifically one that doesn't help me at all.

I thought maybe I could pull the data out of the feature class which the raster catalogs effectively are, but I can't work out what the raster data actually is. If I extract it to an object it doesn't seem to be an IRaster, IRasterDataset or IRasterLayer.

Any ideas?
0 Kudos
1 Reply
JohnHauck
Occasional Contributor II
I've not really worked with raster catalogs much but from the documentation: "A raster catalog is a collection of raster datasets defined in a table format in which each record represents an individual raster dataset in the catalog."

The GdbRasterCatalogLayer CoClass also implements serveral interfaces that will allow you to get access to the feature class or table, I used IFeatureLayer. Then got a IFeatureCursor to loop through the rows and get access to the IRasterValue.

Here is some code for this:

ILayer l = ArcMap.Document.FocusMap.get_Layer(0);
IFeatureClass fc = ((IFeatureLayer)l).FeatureClass;
IFeatureCursor fCur = fc.Search(null, false);
IFeature f = fCur.NextFeature();
IRasterValue2 rastVal = (IRasterValue2)f.get_Value(f.Fields.FindField("Raster"));
IRaster r = rastVal.Raster;
0 Kudos