using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.SpatialAnalystTools;
using ESRI.ArcGIS.esriSystem;
This solution is only works for single band raster. For multi-band raster zonal statistics I will make a separate post soon.
public static void ComputeZonalStatisticsFromEsri(string feature, string zoneField, string valueRaster, string outputTable)
{
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);
UID pUid = new UIDClass();
pUid.Value = "esriSpatialAnalystUI.SAExtension";
// Add Spatial Analyst extension to the license manager.
object v = null;
IExtensionManagerAdmin extensionManagerAdmin = new ExtensionManagerClass();
extensionManagerAdmin.AddExtension(pUid, ref v);
// Enable the license.
IExtensionManager extensionManager = (IExtensionManager)extensionManagerAdmin;
IExtension extension = extensionManager.FindExtension(pUid);
IExtensionConfig extensionConfig = (IExtensionConfig)extension;