Пример #1
0
        private void bt_OK_Click(object sender, EventArgs e)
        {
            if (comboBoxSelect.SelectedItem == null)
            {
                MessageBox.Show("文件不能为空!");
                return;
            }
            //pCreatRalyr = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);
            string strFilePath = GetFileNameByLayer.GetRasterFileName(m_pMap.get_Layer(comboBoxSelect.SelectedIndex));

            //初始化ENVI

            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();

            oComIDL.CreateObject(0, 0, 0);

            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\green.pro'");
            oComIDL.ExecuteString(@"green,'" + strFilePath + "','" + textBoxOutPut.Text + "'");
            oComIDL.DestroyObject();
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = m_pMap;
            openrasterfile.OpenRaster(textBoxOutPut.Text);
            this.Close();
        }
Пример #2
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (cmbInputFile.Text == "")
            {
                MessageBox.Show("输入为空,请选择输入文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (txtbOutput.Visible == true && txtbOutput.Text == "")
            {
                MessageBox.Show("输出为空,请选择输出文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (listBox1.SelectedItems.Count == 0)
            {
                MessageBox.Show("选择分类波段为空,请选择波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else
            {
                COM_IDL_connectLib.COM_IDL_connect oComIDL = new COM_IDL_connectLib.COM_IDL_connect();
                oComIDL.CreateObject(0, 0, 0);
                oComIDL.ExecuteString(".RESET_SESSION");
                string str = ".compile '" + Application.StartupPath + "\\RSImage_KMeans.pro" + "'";
                oComIDL.ExecuteString(str);

                string       inputfile    = string.Empty;
                IRasterLayer pRasterLayer = pMap.get_Layer(cmbInputFile.SelectedIndex) as IRasterLayer;
                for (int i = 0; i < pRasterLayer.BandCount; i++)
                {
                    inputfile = pRasterLayer.FilePath;
                }

                string pos = "[";
                for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
                {
                    pos += (int)listBox1.SelectedIndices[i] + ",";
                }
                pos = pos.Substring(0, pos.Length - 1) + "]";

                string str1 = "RSImage_KMeans" + ",'" + inputfile + "'" + "," + pos + ",'" + txtbOutput.Text + "'" + ",7,'" + dmudMinClass.Text + "'" + ",'" + dmudIterations.Text + "'" + ",'" + txtChangeThresh.Text + "'";
                oComIDL.ExecuteString(str1);

                if (MessageBox.Show("分类成功,是否显示结果?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    openraster_1 openrasterfile = new openraster_1();
                    openrasterfile.pMap = pMap;
                    openrasterfile.OpenRaster(txtbOutput.Text);
                    ShowResultOrNot = true;
                    this.Close();
                }
                else
                {
                    this.Close();
                }
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (m_pMap.get_Layer(comboBox2.SelectedIndex) is IRasterLayer)
            {
                MessageBox.Show("选择数据错误!");
                return;
            }
            if (!(m_pMap.get_Layer(comboBox1.SelectedIndex) is IRasterLayer))
            {
                MessageBox.Show("选择数据错误!");
                return;
            }
            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormDescription("正在裁剪.....");      // 信息
            //获得shp文件路径
            IDataLayer     pShpLayer;
            IDatasetName   pDatasetName;
            IWorkspaceName pWSName;

            pShpLayer    = (IDataLayer)m_pMap.get_Layer(comboBox2.SelectedIndex);
            pDatasetName = (IDatasetName)pShpLayer.DataSourceName;
            pWSName      = pDatasetName.WorkspaceName;
            string pFilePath = pWSName.PathName;
            string pFileName = pDatasetName.Name;
            string ShpPath   = pFilePath + "\\" + pFileName + ".shp";

            //获得栅格文件
            IRasterLayer pDataLayer;

            pDataLayer = (IRasterLayer)m_pMap.get_Layer(comboBox1.SelectedIndex);
            //初始化ENVI
            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
            oComIDL.CreateObject(0, 0, 0);
            //这个功能需要调用ENVI
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\startENVI.pro'");
            oComIDL.ExecuteString("startEnvi,/ShowProcess");

            ////执行图像裁剪
            //编译裁剪程序
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\cal_subset.pro'");
            //执行裁剪
            oComIDL.ExecuteString(@"cal_subset,'" + pDataLayer.FilePath + "','" + ShpPath + "','" + textBox1.Text + "'");

            //结束ENVI
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\endENVI.pro'");
            oComIDL.ExecuteString("endEnvi,");
            //加载图像裁剪后影像
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = m_pMap;
            openrasterfile.OpenRaster(textBox1.Text);
            //OpenRaster(textBox1.Text);
            splashScreenManager1.CloseWaitForm();
            this.Close();
        }
Пример #4
0
        private void bt_OK_Click(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormDescription("正在提取水体信息");
            pCreatRalyr = (IRasterLayer)pMap.get_Layer(combo_input.SelectedIndex);
            //初始化ENVI
            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
            oComIDL.CreateObject(0, 0, 0);
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\math_doit_water.pro'");
            oComIDL.ExecuteString(@"math_doit_water,'" + pCreatRalyr.FilePath + "','" + tb_output.Text + "'");
            oComIDL.DestroyObject();
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = pMap;
            openrasterfile.OpenRaster(tb_output.Text);
            //OpenRaster(tb_output.Text);
            splashScreenManager1.CloseWaitForm();
            this.Close();
        }