IZonalOp.ZonalStatisticsAsTable C#

Discussion created by mgambone2 on Dec 19, 2011
Latest reply on Dec 20, 2011 by mgambone2

I'm trying to follow the ArcObject sample codes for calculating zonal statistics as table. I'm not getting an error but at the same time, there is no output.  I notice the difference between this SpatialAnalyst ArcObject and the SpatialAnalystTool's ZonalStatisticsAsTable: The ArcObject version is missing the output table name. I don't know where to specify this in the ArcObject version.  Here's a snippet of my code:

//Create a Feature Class Descriptor object for input shapefile zones
IFeatureClassDescriptor aoiDesc = new FeatureClassDescriptorClass();
string zoneField = "HydroID";
IFeatureClass aoiFc = OpenFeatureClassFromShapefiile(polygonPath, polygonName);
IGeoDataset aoiGds = (IGeoDataset)aoiFc;
aoiDesc.Create(aoiFc, null, zoneField);
aoiGds = (IGeoDataset)aoiDesc;

//Create a Raster Descriptor object for input raster values
IRaster ras = new RasterClass();
ras = OpenRasterDataset(exprasPath, exprasName).CreateDefaultRaster();
IRasterDescriptor rasDesc = new RasterDescriptorClass();
string rasValue = "VALUE";
rasDesc.Create(ras, null, rasValue);
IGeoDataset rasGds = (IGeoDataset)rasDesc;

//Create an instance of the output table object
ITable stats = null;

//Initialize an IZonalOp object
ESRI.ArcGIS.SpatialAnalyst.IZonalOp zoneOp = new ESRI.ArcGIS.SpatialAnalyst.RasterZonalOpClass();

//Perform spatial operation
stats = zoneOp.ZonalStatisticsAsTable(aoiGds, rasGds, true);

Appreciate any suggestion on how to get this to work.