/// <summary> /// Performs an unsupervised iso Clustering Maximum likelyhood classification /// </summary> /// <param name="inRasterDset"> input raster dataset (string, IRaster, IRasterDataset, IRasterDescription) used to perform the isoCluster</param> /// <param name="outWorkSpace">string identifing the output workspace</param> /// <param name="numClasses">int specifing the number of classes</param> /// <param name="outRstPath">the full path of the output Raster. If null will use outWorkSpace and name the raster iso</param> /// <param name="outSigPath">the full path fo the signature file. If null will use outWorkSpace and name signature file isoSig.gsg</param> /// <returns>geoprocessing messages</returns> public string isoClusterUnSupervised(object inRasterDset, IWorkspace outWorkSpace, int numClasses, string outRstPath, string outSigPath) { Forms.RunningProcess.frmRunningProcessDialog frmRd = new Forms.RunningProcess.frmRunningProcessDialog(false); frmRd.addMessage("Running Iso Cluster Unsupervised classification"); frmRd.stepPGBar(10); frmRd.Show(); string outRstStr = null; if (outRstPath == null) { outRstPath = outWorkSpace.PathName + "\\iso"; outSigPath = System.IO.Path.GetDirectoryName(outWorkSpace.PathName) + "\\isoSig.gsg"; } try { gp.OverwriteOutput = true; gp.SetEnvironmentValue("workspace", outWorkSpace.PathName); ESRI.ArcGIS.SpatialAnalystTools.IsoClusterUnsupervisedClassification isoCls = new IsoClusterUnsupervisedClassification(); isoCls.Input_raster_bands = inRasterDset; isoCls.Minimum_class_size = numClasses * 10; isoCls.Number_of_classes = numClasses; isoCls.Output_classified_raster = outRstPath; isoCls.Output_signature_file = outSigPath; isoCls.Sample_interval = 10; IGeoProcessorResult gpRslt = (IGeoProcessorResult)gp.Execute(isoCls, null); frmRd.addMessage(getMessages(gpRslt)); outRstStr = gpRslt.ReturnValue.ToString(); frmRd.stepPGBar(60); } catch (Exception e) { string x = e.ToString(); Console.WriteLine("New Error: " + x); frmRd.addMessage(x); } finally { frmRd.addMessage("Finished IsoCluster"); frmRd.stepPGBar(100); frmRd.enableClose(); frmRd.TopMost = false; } return(outRstStr); }
/// <summary> /// Performs an unsupervised iso Clustering Maximum likelyhood classification /// </summary> /// <param name="inRasterDset"> input raster dataset (string, IRaster, IRasterDataset, IRasterDescription) used to perform the isoCluster</param> /// <param name="outWorkSpace">string identifing the output workspace</param> /// <param name="numClasses">int specifing the number of classes</param> /// <param name="outRstPath">the full path of the output Raster. If null will use outWorkSpace and name the raster iso</param> /// <param name="outSigPath">the full path fo the signature file. If null will use outWorkSpace and name signature file isoSig.gsg</param> /// <returns>geoprocessing messages</returns> public string isoClusterUnSupervised(object inRasterDset, IWorkspace outWorkSpace, int numClasses, string outRstPath, string outSigPath) { Forms.RunningProcess.frmRunningProcessDialog frmRd = new Forms.RunningProcess.frmRunningProcessDialog(false); frmRd.addMessage("Running Iso Cluster Unsupervised classification"); frmRd.stepPGBar(10); frmRd.Show(); string outRstStr = null; if (outRstPath == null) { outRstPath = outWorkSpace.PathName + "\\iso"; outSigPath = System.IO.Path.GetDirectoryName(outWorkSpace.PathName) + "\\isoSig.gsg"; } try { gp.OverwriteOutput = true; gp.SetEnvironmentValue("workspace", outWorkSpace.PathName); ESRI.ArcGIS.SpatialAnalystTools.IsoClusterUnsupervisedClassification isoCls = new IsoClusterUnsupervisedClassification(); isoCls.Input_raster_bands = inRasterDset; isoCls.Minimum_class_size = numClasses * 10; isoCls.Number_of_classes = numClasses; isoCls.Output_classified_raster = outRstPath; isoCls.Output_signature_file = outSigPath; isoCls.Sample_interval = 10; IGeoProcessorResult gpRslt = (IGeoProcessorResult)gp.Execute(isoCls, null); frmRd.addMessage(getMessages(gpRslt)); outRstStr = gpRslt.ReturnValue.ToString(); frmRd.stepPGBar(60); } catch (Exception e) { string x = e.ToString(); Console.WriteLine("New Error: " + x); frmRd.addMessage(x); } finally { frmRd.addMessage("Finished IsoCluster"); frmRd.stepPGBar(100); frmRd.enableClose(); frmRd.TopMost = false; } return outRstStr; }