Thursday, September 24, 2015

Calculate zonal-statistics using ESRI ArcObjects and C#

Be The First To Comment
Import the following references in the project.

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)  
       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;   

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me