Exemplo n.º 1
0
        /*
         * private void classification_Click(object sender, EventArgs e)
         * {
         *  //获取参数
         *  int ClassNums = int.Parse(textBox2.Text);
         *  int SampleStep = int.Parse(textBox3.Text);
         *  int MaxLoopCount =int.Parse(textBox4.Text) ;
         *  double MoveThrs = double.Parse(textBox5.Text);
         *  //int MinCellNums = int.Parse(textBox9.Text);
         *  int MinCellNums = Convert.ToInt32(double.Parse(textBox9.Text) * width * height);
         *  double MaxStd = double.Parse(textBox8.Text);
         *  int MaxLumpNums = int.Parse(textBox7.Text);
         *  double MinInterClassDist = double.Parse(textBox6.Text);
         *  string DstRasURL = textBox1.Text;
         *  int RBand = int.Parse(System.Text.RegularExpressions.Regex.Replace(RBandCmb.Text, @"[^0-9]+", ""));
         *  int GBand = int.Parse(System.Text.RegularExpressions.Regex.Replace(GBandCmb.Text, @"[^0-9]+", ""));
         *  int BBand = int.Parse(System.Text.RegularExpressions.Regex.Replace(BBandCmb.Text, @"[^0-9]+", ""));
         *
         *  selectBands[0] = RBand;
         *  selectBands[1] = GBand;
         *  selectBands[2] = BBand;
         *
         *  if (selectRasterCmb.Items.Contains(textBox1.Text))
         *  {
         *      MessageBox.Show("该文件已存在!请重新输入文件名。");
         *      textBox1.Text = "";
         *      return;
         *  }
         *
         *
         *  rds = themeLayer.GetData() as RasterDataSet;
         *  //MessageBox.Show(rds.ClsName);
         *  //构建栅格分类器
         *  RasClass rc = new RasClass();
         *  //设置待分类影像
         *  rc.SetData(rds);
         *  //设置处理范围
         *  rc.SetCommonParam(selectBands,0,0,height,width);
         *  //设置分类结果URL
         *  DstRasURL = "GDBP://MapGisLocal/" + selectDBCmb.Text + "/ras/"+ textBox1.Text;
         *  //调用分类器
         *  //监督分类:最大似然法
         *  int i = rc.RsMaxLiklihoodSupervisedClassification(0.1, DstRasURL);
         *  //非监督分类:ISODATA
         *  //int i = rc.RsIsoClusterUnsupervisedClassification(ClassNums, MaxStd, MaxLoopCount, MoveThrs, MinInterClassDist, MinCellNums, MaxLumpNums, SampleStep, DstRasURL);
         *  selectRasterCmb.Items.Add(textBox1.Text);
         *
         *
         *  if (i == 1) {
         *      MessageBox.Show("分类成功!");
         *      //将分类结果展示到界面上
         *      rds.Open(textBox1.Text, 0);
         *      Map map = new Map();
         *      themeLayer = new RasterLayer();
         *
         *      if (rds != null)
         *          themeLayer.AttachData(rds);
         *
         *      map.Append(themeLayer);
         *      this.mapControl.ActiveMap = map;
         *      mapControl.Refresh();
         *
         *      //获取分类结果
         *      after_cls_rds.OpenByURL(DstRasURL, RasAccessType.RasAccessType_Update);
         *      //如果是监督分类,需要给结果集设置AOI;
         *      //after_cls_rds.SetAOIs((AOIPloygon[])rds.GetAOIs().Clone());
         *      after_cls_rds = setaoi(rds, after_cls_rds);
         *      MessageBox.Show("分类结果的aoi有:"+after_cls_rds.GetAOIs().Length.ToString());
         *      //分类结果精度评定
         *      RasClassificationAnalyse rca = new RasClassificationAnalyse();
         *      //设置待评价影像(分类结果)
         *      rca.SetData(after_cls_rds,after_cls_rds.BandCount);
         *      //设置处理范围
         *      rca.SetCommonParam(0, 0, height, width);
         *
         *      int j = rca.RsClassificationAccuracyAnalyse(rds, true, true, true, true, "classifaction_ana1.txt");
         *      MessageBox.Show("精度评定" + j.ToString());
         *  }
         *  else{
         *      MessageBox.Show("分类失败");
         *  }
         * }
         */
        private RasterDataSet setaoi(RasterDataSet oldrds, RasterDataSet newrds)
        {
            //设置AOI信息
            AOIPloygon[] oldaois = oldrds.GetAOIs();
            AOIPloygon[] newaois = newrds.GetAOIs();
            AOIPloygon   aoi     = new AOIPloygon();

            for (int i = 0; i < oldaois.Length; i++)
            {
                newaois[i].R = oldaois[i].R;
                newaois[i].G = oldaois[i].G;
                newaois[i].B = oldaois[i].B;
            }
            bool flag = newrds.SetAOIs(newaois);

            if (flag)
            {
                MessageBox.Show("AOI信息设置成功");
                return(newrds);
            }
            else
            {
                MessageBox.Show("AOI信息设置失败");
                return(null);
            }
        }