示例#1
0
        /// <summary>
        /// 获取分辨率最高的栅格计算操作类
        /// </summary>
        /// <param name="referencedRaster"></param>
        /// <param name="cellSize"></param>
        /// <returns></returns>
        private static IMapAlgebraOp GetAlgebraOp(IRaster referencedRaster, double cellSize)
        {
            //实例化栅格运算工具
            IMapAlgebraOp mapAlgebraOp = new RasterMapAlgebraOp() as IMapAlgebraOp;

            //以分辨率最高的栅格为参考对象
            RasterAnalysisEnvironmentClass.SetAnalysisEnvironment(mapAlgebraOp, referencedRaster, cellSize);
            return(mapAlgebraOp);
        }
示例#2
0
        //
        //执行
        //
        private void btnRun_Click(object sender, EventArgs e)
        {
            frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息");

            try
            {
                frmWait.Owner   = this;
                frmWait.TopMost = false;
                //获取组合的条件运算公式,若检查失败,提示并返回
                RasterMapAlgebraOp op  = new RasterMapAlgebraOp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], DecisionTree.variableTable);
                string             msg = "";
                if (!op.CheckExp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], out msg))
                {
                    XtraMessageBox.Show(msg);
                    return;
                }
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Title  = "保存结果文件";
                dialog.Filter = "tiff(*.tif)|*.tif|All files(*.*)|*.*";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    op.Execute(dialog.FileName);
                }
                //元数据
                if (_treeFile.Contains("gf4.tree"))
                {
                    BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "GF4", "", "长时间序列识别结果", "作物识别结果");
                    meta.WriteGeoMeta();
                }
                else
                {
                    BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "", "", "决策树识别结果", "作物识别结果");
                    meta.WriteGeoMeta();
                }
                //快视图
                BLL.ProductQuickView view = new BLL.ProductQuickView(dialog.FileName);
                view.Create();

                if (DialogResult.OK == XtraMessageBox.Show("分类完毕,是否加分类载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                {
                    MAP.AddRasterFileToMap(dialog.FileName);
                }
                //this.Close();
            }
            catch (Exception ex)
            { XtraMessageBox.Show("分类失败:" + ex.Message); }
            finally
            {
                frmWait.Close();
            }
        }