public static string ContinuousToClassifiedMRR(string strInFilePath, string strOutFilePath) { const ClassificationType outClassType = ClassificationType.Classified; UndefinedClassInfo undefinedClassInfo = new UndefinedClassInfo(); undefinedClassInfo.SetNullForUndefinedRange = false; undefinedClassInfo.UndefinedClassColor = Color.FromArgb(0, 128, 64, 0); undefinedClassInfo.UndefinedClassLabel = "Undefined"; undefinedClassInfo.UndefinedValue = -9999; ClassInfo[] newClassInfo = new ClassInfo[5]; //Initalize class items for (int i = 0; i < newClassInfo.Length; i++) { newClassInfo[i] = new ClassInfo(); } //Set classify ranges newClassInfo[0].LowerBound = 0.0f; newClassInfo[0].UpperBound = 4.0f; newClassInfo[1].LowerBound = 4.0f; newClassInfo[1].UpperBound = 8.0f; newClassInfo[2].LowerBound = 8.0f; newClassInfo[2].UpperBound = 12.0f; newClassInfo[3].LowerBound = 12.0f; newClassInfo[3].UpperBound = 16.0f; newClassInfo[4].LowerBound = 16.0f; newClassInfo[4].UpperBound = 20.0f; //Set new class values newClassInfo[0].NewValue = 4.0f; newClassInfo[1].NewValue = 8.0f; newClassInfo[2].NewValue = 12.0f; newClassInfo[3].NewValue = 16.0f; newClassInfo[4].NewValue = 20.0f; //Set new class names newClassInfo[0].NewLabel = "0 - 4"; newClassInfo[1].NewLabel = "4 - 8"; newClassInfo[2].NewLabel = "8 - 12"; newClassInfo[3].NewLabel = "12 -16"; newClassInfo[4].NewLabel = "16 - 20"; //Set new class color newClassInfo[0].NewColor = Color.FromArgb(0, 0, 255, 255); //cyan newClassInfo[1].NewColor = Color.FromArgb(0, 255, 128, 192); //Pink Color newClassInfo[2].NewColor = Color.FromArgb(0, 255, 128, 64); //Orange newClassInfo[3].NewColor = Color.FromArgb(0, 128, 0, 255); newClassInfo[4].NewColor = Color.FromArgb(0, 255, 0, 0); RasterAnalysis.ClassifyRaster(strInFilePath, strOutFilePath, "MI_MRR", outClassType, newClassInfo, undefinedClassInfo); return(strOutFilePath); }
public static string RegionInspectionBands(string strInTABFilePath , string[] strInRasterFilesPath , int fieldIndex , int bandIndex , string strOutTABFilePath , bool bMinimumValue , bool bMaximumValue , bool bAverageValue , bool bMedianValue , bool bNumCells , bool bNumNullCells , bool bCoefficientOfVariance , bool bRange , bool bStandardDeviation , bool bSumOfCells , bool bLowerQuartile , bool bUpperQuartile , bool bInterQuartileRange ) { PolygonStatisticFlags inStatsFlag = new PolygonStatisticFlags { Min = bMinimumValue, Max = bMaximumValue, Mean = bAverageValue, Median = bMedianValue, TotalCells = bNumCells, TotalNullCells = bNumNullCells, CoefficientOfVariance = bCoefficientOfVariance, Range = bRange, StandardDeviation = bStandardDeviation, SumOfCells = bSumOfCells, LowerQuartile = bLowerQuartile, UpperQuartile = bUpperQuartile, InterQuartileRange = bInterQuartileRange }; RasterAnalysis.GetPolygonStatistics(strInTABFilePath, strInRasterFilesPath, strOutTABFilePath, inStatsFlag, (uint)fieldIndex, (uint)bandIndex); return(strOutTABFilePath); }
private void iDW空间差值ToolStripMenuItem_Click(object sender, EventArgs e) { //用反距离IDW插值生成的栅格图像 IInterpolationOp pInterpolationOp = new RasterInterpolationOpClass(); // 输入点图层 IFeatureClass pFeatureClass; IFeatureLayer pFeaturelayer; int indexLayer = Convert.ToInt32(Interaction.InputBox("请输入IDW空间插值点图层下标", "字符串", "", 500, 250)); pFeaturelayer = this.axMapControl1.Map.get_Layer(indexLayer) as IFeatureLayer; pFeatureClass = pFeaturelayer.FeatureClass; // Define the search radius IRasterRadius pRadius = new RasterRadiusClass(); object maxDistance = Type.Missing; pRadius.SetVariable(12, ref maxDistance); //Create FeatureClassDescriptor using a value field IFeatureClassDescriptor pFCDescriptor = new FeatureClassDescriptorClass(); string zValue = Interaction.InputBox("请输入特征字段(yelvsuA/FYyelvsuA)", "字符串", "", 500, 250); pFCDescriptor.Create(pFeatureClass, null, zValue); //set { cellsize for output raster in the environment object dCellSize = 113.039027413432; IRasterAnalysisEnvironment pEnv = new RasterAnalysis(); pEnv = pInterpolationOp as IRasterAnalysisEnvironment; pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dCellSize); object objectbarrier = Type.Missing; //Perform the interpolation IGeoDataset rasDataset = pInterpolationOp.IDW((IGeoDataset)pFCDescriptor, 2, pRadius, ref objectbarrier); IRaster pOutRaster = rasDataset as IRaster; //Add output into ArcMap as a raster layer IRasterLayer pOutRasLayer = new RasterLayerClass(); pOutRasLayer.CreateFromRaster(pOutRaster); this.axMapControl1.AddLayer(pOutRasLayer, 0); axMapControl1.ActiveView.Refresh(); DialogResult dr = MessageBox.Show("插值成功,请选择是否进行分级渲染", "分级渲染选择", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dr == DialogResult.OK) { //用户选择确认的操作(分级渲染) IRasterLayer pRasterLayer = null; for (int i = 0; i < axMapControl1.LayerCount; i++) { if (axMapControl1.get_Layer(i) is IRasterLayer) { pRasterLayer = axMapControl1.get_Layer(i) as IRasterLayer; } } if (pRasterLayer == null) { MessageBox.Show("当前图层不存在栅格图层"); return; } int number = Convert.ToInt32(Interaction.InputBox("请输入栅格影像分类数量(默认为10)", "字符串", "", 500, 250)); if (number == 0) { number = 10; } funColorForRaster_Classify(pRasterLayer, number); axMapControl1.ActiveView.Refresh(); } else if (dr == DialogResult.Cancel) { //用户选择取消的操作 return; } }