コード例 #1
0
        private void btnSegment_Click(object sender, EventArgs e)
        {
            int    CovVl   = trbCover.Value;
            int    HtVl    = trbHeight.Value;
            bool   Asp     = chbAspect.Checked;
            double minArea = System.Convert.ToDouble(nudMin.Value);
            double maxArea = System.Convert.ToDouble(nudMax.Value);
            string wksPath = txtLandFireDir.Text;

            if (wksPath == "" || wksPath == null)
            {
                MessageBox.Show("You must select a workspace that has LandFire Data");
                return;
            }
            IWorkspace wks = geoUtil.OpenWorkSpace(wksPath);

            RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false);
            rd.Show(this);
            DateTime dt1 = DateTime.Now;

            try
            {
                rd.addMessage("Segmenting LandFireData...");
                rd.stepPGBar(25);
                rd.Refresh();
                lf.LandFireWorkspace = wks;
                lf.CoverLevels       = CovVl;
                lf.HeightLevels      = HtVl;
                lf.UseAspect         = Asp;
                lf.MaxArea           = maxArea;
                lf.MinArea           = minArea;
                rd.addMessage("Performing Raster Analyses");
                rd.Refresh();
                lf.segmentLandFireData();
                rd.addMessage("Converting to Polygons");
                rd.Refresh();
                lf.convertToPolygon();
                rd.addMessage("Splitting Polygons");
                lf.splitPolygons(false);
            }
            catch (Exception ex)
            {
                rd.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt1);
                rd.addMessage("Finished Segmenting LandFire Data in " + ts.TotalMinutes.ToString() + " minutes.");
                rd.Refresh();
                rd.stepPGBar(100);
                rd.enableClose();
            }
        }
        private void btnSegment_Click(object sender, EventArgs e)
        {
            int CovVl = trbCover.Value;
            int HtVl = trbHeight.Value;
            bool Asp = chbAspect.Checked;
            double minArea = System.Convert.ToDouble(nudMin.Value);
            double maxArea = System.Convert.ToDouble(nudMax.Value);
            string wksPath = txtLandFireDir.Text;
            if (wksPath == "" || wksPath == null)
            {
                MessageBox.Show("You must select a workspace that has LandFire Data");
                return;
            }
            IWorkspace wks = geoUtil.OpenWorkSpace(wksPath);
            RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false);
            rd.Show(this);
            DateTime dt1 = DateTime.Now;
            try
            {
                rd.addMessage("Segmenting LandFireData...");
                rd.stepPGBar(25);
                rd.Refresh();
                lf.LandFireWorkspace = wks;
                lf.CoverLevels = CovVl;
                lf.HeightLevels = HtVl;
                lf.UseAspect = Asp;
                lf.MaxArea = maxArea;
                lf.MinArea = minArea;
                rd.addMessage("Performing Raster Analyses");
                rd.Refresh();
                lf.segmentLandFireData();
                rd.addMessage("Converting to Polygons");
                rd.Refresh();
                lf.convertToPolygon();
                rd.addMessage("Splitting Polygons");
                lf.splitPolygons(false);
            }
            catch (Exception ex)
            {

                rd.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt1);
                rd.addMessage("Finished Segmenting LandFire Data in " + ts.TotalMinutes.ToString() + " minutes.");
                rd.Refresh();
                rd.stepPGBar(100);
                rd.enableClose();

            }
        }
コード例 #3
0
        private void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm   = cmbInRaster1.Text;
            string outNm   = txtOutName.Text;
            string pixelNm = cmbPixel.Text;

            if (pixelNm == "" || pixelNm == null || rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNm == "" || outNm == null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Transforming Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                IRaster      rst   = rstDic[rstNm];
                rstPixelType pType = (rstPixelType)Enum.Parse(typeof(rstPixelType), pixelNm);
                outraster = rsUtil.returnRaster(rst, pType);
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");

                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = outNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Converting Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #4
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm  = cmbdataset.Text;
            string mdPath = txtOutputPath.Text;
            string pfr    = txtPrefix.Text;
            int    t1;
            double d;

            if (Int32.TryParse(pfr, out t1) || Double.TryParse(pfr, out d))
            {
                pfr = "";
            }
            string linkFldName = cmbField.Text;

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify an input dataset", "No Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mdPath == null || mdPath == "")
            {
                MessageBox.Show("You must specify a zonal dataset", "No Zonal Dataset", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ITable tbl  = rstDic[rstNm];
            ITable ztbl = rstDic[mdPath];

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Transforming data. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            rp.Refresh();
            try
            {
                Statistics.ModelHelper.runProgressBar("Transposing Zonal Data");
                FunctionRasters.zonalHelper.transformData(tbl, linkFldName, ztbl, pfr);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished calculations" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #5
0
        private void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm = cmbInRaster1.Text;
            int    sk    = System.Convert.ToInt32(nudSkip.Value);

            if (rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Calculating Statistics. This may take a while...");
            rp.Show();
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                IRaster rst = rstDic[rstNm];
                outraster = rsUtil.calcStatsAndHist(rst, sk);
                if (mp != null && addToMap)
                {
                    rp.Refresh();
                    for (int i = 0; i < mp.LayerCount; i++)
                    {
                        ILayer ly = mp.get_Layer(i);
                        if (ly.Name == rstNm)
                        {
                            mp.DeleteLayer(ly);
                        }
                    }
                    IRasterLayer rstLyr = new RasterLayerClass();
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = rstNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Calculating Statistics" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string rstNm   = cmbRaster.Text;
            string wksNm   = txtWorkspace.Text;
            string outNm   = txtOutName.Text;
            string outType = cmbType.Text;
            int    blSize  = System.Convert.ToInt32(nudBS.Value);

            if (outWks == null || wksNm == "" || wksNm == null || rstNm == "" || rstNm == null || outNm == "" || outNm == null)
            {
                MessageBox.Show("Raster, Workspace, or Output Name are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object noDataVl = null;

            if (rsUtil.isNumeric(txtNoDataVl.Text) && txtNoDataVl.Visible)
            {
                noDataVl = System.Convert.ToDouble(txtNoDataVl.Text);
            }
            rasterUtil.rasterType rType = (rasterUtil.rasterType)Enum.Parse(typeof(rasterUtil.rasterType), outType);
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Saving raster");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();

            DateTime dt1 = DateTime.Now;

            try
            {
                IRaster        rs     = rstDic[rstNm];
                IRasterDataset rsDset = rsUtil.saveRasterToDatasetM(rs, outNm, outWks, rType, noDataVl, blSize, blSize);
                DateTime       dt2    = DateTime.Now;
                IRasterLayer   rsLyr  = new RasterLayerClass();
                rsLyr.CreateFromDataset(rsDset);
                rsLyr.Name    = outNm;
                rsLyr.Visible = false;
                mp.AddLayer((ILayer)rsLyr);
                TimeSpan ts      = dt2.Subtract(dt1);
                string   prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #7
0
        private void btnSample_Click(object sender, EventArgs e)
        {
            string smpFtrNm  = cmbSampleFeatureClass.Text;
            string rstNm     = cmbRaster.Text;
            string clsTypeNm = cmbCluster.Text;

            if (smpFtrNm == null || smpFtrNm == "" || rstNm == "" || rstNm == null || clsTypeNm == null || clsTypeNm == "")
            {
                MessageBox.Show("sample location, raster, or cluster type are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Dictionary <double, double> azDsDic = new Dictionary <double, double>();

            for (int i = 0; i < dgvAzDs.RowCount; i++)
            {
                double az = System.Convert.ToDouble(dgvAzDs[0, i].Value);
                double ds = System.Convert.ToDouble(dgvAzDs[1, i].Value);
                if (!azDsDic.ContainsKey(az))
                {
                    azDsDic.Add(az, ds);
                }
            }
            if (azDsDic.Count < 1)
            {
                MessageBox.Show("Nothing specified for offset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            rasterUtil.clusterType clsType = (rasterUtil.clusterType)Enum.Parse(typeof(rasterUtil.clusterType), clsTypeNm);
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Sampling raster");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();
            DateTime dt1 = DateTime.Now;

            try
            {
                rsUtil.sampleRaster(ftrDic[smpFtrNm], rstDic[rstNm], rstNm, azDsDic, clsType);
                DateTime dt2     = DateTime.Now;
                TimeSpan ts      = dt2.Subtract(dt1);
                string   prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #8
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            string inFtrNm  = cmbSampleFeatureClass.Text;
            string outCsvNm = txtCSV.Text;

            if (inFtrNm == "" || inFtrNm == null || outCsvNm == "" || outCsvNm == null)
            {
                MessageBox.Show("You must specify both a feature class and a output CSV file name");
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            System.DateTime dt1 = DateTime.Now;
            rp.addMessage("Exporting samples to the following location:\n" + outCsvNm);
            rp.stepPGBar(50);
            rp.Show();
            rp.Refresh();
            try
            {
                IFeatureClass ftrCls = ftrDic[inFtrNm];
                geoUtil.exportTableToTxt((ITable)ftrCls, System.IO.Path.GetDirectoryName(outCsvNm), System.IO.Path.GetFileName(outCsvNm));
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt1);
                string   dur = "Export took " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds to complete.";
                rp.addMessage(dur);
                rp.stepPGBar(100);
                rp.addMessage("Finished exporting samples");
                rp.enableClose();
                rp.Refresh();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = cmbdataset.Text;
     string mdPath = txtOutputPath.Text;
     string pfr = txtPrefix.Text;
     int t1;
     double d;
     if (Int32.TryParse(pfr, out t1)||Double.TryParse(pfr,out d)) pfr = "";
     string linkFldName = cmbField.Text;
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify an input dataset","No Input",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (mdPath == null || mdPath == "")
     {
         MessageBox.Show("You must specify a zonal dataset","No Zonal Dataset",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     ITable tbl = rstDic[rstNm];
     ITable ztbl = rstDic[mdPath];
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Transforming data. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     rp.Refresh();
     try
     {
         Statistics.ModelHelper.runProgressBar("Transposing Zonal Data");
         FunctionRasters.zonalHelper.transformData(tbl,linkFldName, ztbl, pfr);
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         Statistics.ModelHelper.closeProgressBar();
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished calculations" + t);
         rp.enableClose();
         this.Close();
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string rstNm = cmbRaster.Text;
            string wksNm = txtWorkspace.Text;
            string outNm = txtOutName.Text;
            string outType = cmbType.Text;
            int blSize = System.Convert.ToInt32(nudBS.Value);
            if (outWks == null || wksNm == "" || wksNm == null || rstNm == "" || rstNm == null || outNm==""||outNm==null)
            {
                MessageBox.Show("Raster, Workspace, or Output Name are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object noDataVl = null;
            if (rsUtil.isNumeric(txtNoDataVl.Text)&&txtNoDataVl.Visible) noDataVl = System.Convert.ToDouble(txtNoDataVl.Text);
            rasterUtil.rasterType rType = (rasterUtil.rasterType)Enum.Parse(typeof(rasterUtil.rasterType), outType);
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Saving raster");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();

            DateTime dt1 = DateTime.Now;
            try
            {
                IRaster rs = rstDic[rstNm];
                IRasterDataset rsDset = rsUtil.saveRasterToDatasetM(rs, outNm, outWks, rType, noDataVl,blSize,blSize);//rsUtil.saveRasterToDataset(rs, outNm, outWks);
                DateTime dt2 = DateTime.Now;
                IRasterLayer rsLyr = new RasterLayerClass();
                rsLyr.CreateFromDataset(rsDset);
                rsLyr.Name = outNm;
                rsLyr.Visible = false;
                mp.AddLayer((ILayer)rsLyr);
                TimeSpan ts = dt2.Subtract(dt1);
                string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #11
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm  = cmbSampleFeatureClass.Text;
            string mdPath = txtOutputPath.Text;

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mdPath == null || mdPath == "")
            {
                MessageBox.Show("You must specify a model path", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ITable tbl = rstDic[rstNm];

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Predicting new data. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                Statistics.ModelHelper.runProgressBar("Predicting data");
                Statistics.ModelHelper br = new Statistics.ModelHelper(mdPath);
                rp.Refresh();
                br.predictNewData(tbl, qf);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished calculations" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = cmbSampleFeatureClass.Text;
     string mdPath = txtOutputPath.Text;
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify a output name","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (mdPath == null || mdPath == "")
     {
         MessageBox.Show("You must specify a model path","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     ITable tbl = rstDic[rstNm];
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Predicting new data. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     try
     {
         Statistics.ModelHelper.runProgressBar("Predicting data");
         Statistics.ModelHelper br = new Statistics.ModelHelper(mdPath);
         rp.Refresh();
         br.predictNewData(tbl,qf);
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         Statistics.ModelHelper.closeProgressBar();
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished calculations" + t);
         rp.enableClose();
         this.Close();
     }
 }
 private void btnExport_Click(object sender, EventArgs e)
 {
     string inFtrNm = cmbSampleFeatureClass.Text;
     string outCsvNm = txtCSV.Text;
     if (inFtrNm == "" || inFtrNm == null || outCsvNm == "" || outCsvNm == null)
     {
         MessageBox.Show("You must specify both a feature class and a output CSV file name");
         return;
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     System.DateTime dt1 = DateTime.Now;
     rp.addMessage("Exporting samples to the following location:\n" + outCsvNm);
     rp.stepPGBar(50);
     rp.Show();
     rp.Refresh();
     try
     {
         IFeatureClass ftrCls = ftrDic[inFtrNm];
         geoUtil.exportTableToTxt((ITable)ftrCls,System.IO.Path.GetDirectoryName(outCsvNm),System.IO.Path.GetFileName(outCsvNm));
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt1);
         string dur = "Export took " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds to complete.";
         rp.addMessage(dur);
         rp.stepPGBar(100);
         rp.addMessage("Finished exporting samples");
         rp.enableClose();
         rp.Refresh();
         this.Close();
     }
 }
コード例 #14
0
        public string sumSedimentValues()
        {
            string outCSV = graphDir + "\\SedimentByArivalTime.csv";

            using (System.IO.StreamWriter swr = new System.IO.StreamWriter(outCSV))
            {
                string ln = "Alternative,Fires,Period,Sed10,Sed50,Sed10_A,Sed50_A,ArivalTime,CellCount";
                swr.WriteLine(ln);
                if (iterLst.Count < 2)
                {
                    Console.WriteLine("copying files over");
                    copyNaToResults(ref iterLst);
                }
                int    iterCnt = 0;
                string itop    = "";
                foreach (int iter in iterLst)
                {
                    if (iterCnt == 0)
                    {
                        itop = "No Action";
                    }
                    else
                    {
                        itop = "Optimum";
                    }
                    iterCnt++;
                    createPeriodRasters(iter);
                    for (int f = 1; f <= numFir; f++)
                    {
                        for (int i = 1; i <= numPer; i++)
                        {
                            string strln = "Building raster for iteration " + iter.ToString() + " fire " + f.ToString() + " period " + i.ToString();
                            if (rpForm != null)
                            {
                                rpForm.addMessage(strln);
                                rpForm.stepPGBar(5);
                                rpForm.Refresh();
                            }
                            else
                            {
                                Console.WriteLine(strln);
                            }
                            //treatment rasters
                            IFunctionRasterDataset perRs          = periodRasterLst[i - 1];
                            IFunctionRasterDataset noActionPeriod = rsUtil.calcEqualFunction(perRs, 0);
                            IFunctionRasterDataset t10            = rsUtil.calcArithmaticFunction(perRs, rst1Fine10, esriRasterArithmeticOperation.esriRasterMultiply);
                            IFunctionRasterDataset f10            = rsUtil.calcArithmaticFunction(noActionPeriod, rsfine10, esriRasterArithmeticOperation.esriRasterMultiply);
                            IFunctionRasterDataset t50            = rsUtil.calcArithmaticFunction(perRs, rst1Fine50, esriRasterArithmeticOperation.esriRasterMultiply);
                            IFunctionRasterDataset f50            = rsUtil.calcArithmaticFunction(noActionPeriod, rsfine50, esriRasterArithmeticOperation.esriRasterMultiply);
                            IFunctionRasterDataset sum10          = rsUtil.calcArithmaticFunction(t10, f10, esriRasterArithmeticOperation.esriRasterPlus);
                            IFunctionRasterDataset sum50          = rsUtil.calcArithmaticFunction(t50, f50, esriRasterArithmeticOperation.esriRasterPlus);
                            //flamelength rasters
                            string flameRasterPath         = resultsDir + "\\nodeflamelength" + iter.ToString() + "_" + f.ToString() + "_" + i.ToString() + ".txt";
                            IFunctionRasterDataset flmLng  = rsUtil.createIdentityRaster(flameRasterPath);
                            IFunctionRasterDataset flmBool = createBooleanFlame(flmLng);
                            //combined raster
                            IFunctionRasterDataset final10 = rsUtil.conditionalRasterFunction(flmBool, rshsf10, sum10);
                            IFunctionRasterDataset final50 = rsUtil.conditionalRasterFunction(flmBool, rshsf50, sum50);
                            //arrival zones
                            string ArivalRasterPath          = resultsDir + "\\arrivaltime" + iter.ToString() + "_" + f.ToString() + "_" + i.ToString() + ".txt";
                            IFunctionRasterDataset ariv      = rsUtil.createIdentityRaster(ArivalRasterPath);
                            IFunctionRasterDataset arivZones = createArivaltimeZones(ariv);
                            strln = "Summarizing arrival zones for iteration " + iter.ToString() + " fire " + f.ToString() + " period " + i.ToString();
                            if (rpForm != null)
                            {
                                rpForm.addMessage(strln);
                                rpForm.stepPGBar(5);
                                rpForm.Refresh();
                            }
                            else
                            {
                                Console.WriteLine(strln);
                            }
                            ln = getSummaryValue(itop, f, i, final10, final50, arivZones);
                            swr.Write(ln);
                            if (createinter)
                            {
                                strln = "Saving all intermediate rasters...";
                                if (rpForm != null)
                                {
                                    rpForm.addMessage(strln);
                                    rpForm.stepPGBar(5);
                                    rpForm.Refresh();
                                }
                                else
                                {
                                    Console.WriteLine(strln);
                                }
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(noActionPeriod), "noAct_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(t10), "t10_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(f10), "na10_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(t50), "t50_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(f50), "na50_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(sum10), "s10_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(sum50), "s50_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(flmBool), "flm_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(final10), "fl10_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(final50), "fl50_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                rsUtil.saveRasterToDataset(rsUtil.createRaster(arivZones), "az" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                            }
                            if (createcore)
                            {
                                if (!createinter)
                                {
                                    strln = "Saving core rasters...";
                                    if (rpForm != null)
                                    {
                                        rpForm.addMessage(strln);
                                        rpForm.stepPGBar(5);
                                        rpForm.Refresh();
                                    }
                                    else
                                    {
                                        Console.WriteLine(strln);
                                    }
                                    rsUtil.saveRasterToDataset(rsUtil.createRaster(final10), "fl10_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                    rsUtil.saveRasterToDataset(rsUtil.createRaster(final50), "fl50_" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                    rsUtil.saveRasterToDataset(rsUtil.createRaster(arivZones), "az" + iter.ToString() + f + i.ToString(), wks, rasterUtil.rasterType.IMAGINE);
                                }
                            }
                            if (!createcore && !createinter)
                            {
                                try
                                {
                                    if (sedRaster != null)
                                    {
                                        rsUtil.deleteRasterDataset(((IRasterDataset)sedRaster).CompleteName);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e.ToString());
                                }
                            }
                        }
                    }
                }
                swr.Close();
            }
            outcsvpath = outCSV;
            //removelocks();
            return(outCSV);
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = txtOutNm.Text;
     string rstIn = cmbInRaster1.Text;
     if (rstNm == null || rstNm == ""||rstIn==null||rstIn=="")
     {
         MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (dgvRanges.Rows.Count < 1)
     {
         MessageBox.Show("You must have at least on range of values selected", "No Ranges", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRemapFilter rfilt = new RemapFilterClass();
     for (int i = 0; i < dgvRanges.Rows.Count; i++)
     {
         object obj1 = dgvRanges[0, i].Value;
         object obj2 = dgvRanges[1, i].Value;
         object obj3 = dgvRanges[2, i].Value;
         if ( Convert.IsDBNull(obj1)) obj1 = 0;
         if (Convert.IsDBNull(obj2)) obj2 = 0;
         if (Convert.IsDBNull(obj3)) obj3 = 0;
         double min = System.Convert.ToDouble(obj1);
         double max = System.Convert.ToDouble(obj2);
         double vl = System.Convert.ToDouble(obj3);
         rfilt.AddClass(min,max,vl);
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Remapping Rasters. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     try
     {
         outraster = rsUtil.returnRaster(rsUtil.calcRemapFunction(rstDic[rstIn],rfilt));
         if (mp != null && addToMap)
         {
             rp.addMessage("Calculating Statistics...");
             rp.Show();
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
             rstLyr.CreateFromRaster(outraster);
             rstLyr.Name = rstNm;
             rstLyr.Visible = false;
             mp.AddLayer(rstLyr);
         }
         outrastername = rstNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Remapping Rasters" + t);
         rp.enableClose();
         this.Close();
     }
 }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = txtOutNm.Text;
     string funNm = cmbFunction.Text;
     int before = System.Convert.ToInt32(nudBefore.Value);
     int after = System.Convert.ToInt32(nudAfter.Value);
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify a output name","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (lsbRaster.Items.Count < 1)
     {
         MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if ( funNm==null||funNm=="")
     {
         MessageBox.Show("You must select at least on function", "No Function Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRasterBandCollection rsBc = new RasterClass();
     for (int i = 0; i < lsbRaster.Items.Count; i++)
     {
         rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]);
     }
     IFunctionRasterDataset fdset = rsUtil.compositeBandFunction(rsBc);
     rasterUtil.localType op = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType),funNm);
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Calculating raster values. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     try
     {
         outraster = rsUtil.focalBandfunction(fdset,op,before,after);
         //rp.addMessage("Number of bands = " + ((IRasterBandCollection)outraster).Count);
         if (mp != null&&addToMap)
         {
             rp.addMessage("Calculating Statistics...");
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
             rstLyr.CreateFromDataset((IRasterDataset)outraster);
             rstLyr.Name = rstNm;
             rstLyr.Visible = false;
             mp.AddLayer(rstLyr);
         }
         outrastername = rstNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Creating Rasters" + t);
         rp.enableClose();
         this.Close();
     }
 }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     if (!System.IO.Directory.Exists(resultsDir))
     {
         MessageBox.Show("You must select both a OpFuels Project and Scenerio before you can execute.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     //gSed.CellSize = System.Convert.ToDouble(nudCellSize.Value);
     //gSed.ArrivalClass = (graphSedimentByArivalTime.ArrivalClasses)Enum.Parse(typeof(graphSedimentByArivalTime.ArrivalClasses),cmbArrival.Text);
     gSed.CreateIntermediateRasters = chbIntermidiate.Checked;
     gSed.CreateCoreRasters = chbCore.Checked;
     gSed.FlameLength = System.Convert.ToDouble(nudFlameLength.Value);
     if (cmbF10.Text != "")
     {
         gSed.Fine10Field = cmbF10.Text;
     }
     else
     {
         MessageBox.Show("You must specify a NA10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbF50.Text != "")
     {
         gSed.Fine50Field = cmbF50.Text;
     }
     else
     {
         MessageBox.Show("You must specify a NA50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbT10.Text != "")
     {
         gSed.T1_Fine_10Field = cmbT10.Text;
     }
     else
     {
         MessageBox.Show("You must specify a TR10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbT50.Text != "")
     {
         gSed.T1_Fine_50Field = cmbT50.Text;
     }
     else
     {
         MessageBox.Show("You must specify a TR50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbHSF10.Text != "")
     {
         gSed.HSF10Field = cmbHSF10.Text;
     }
     else
     {
         MessageBox.Show("You must specify a HS10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbHSF50.Text != "")
     {
         gSed.HSF50Field = cmbHSF50.Text;
     }
     else
     {
         MessageBox.Show("You must specify a HS50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cmbInFeatureClass.Text == "" || cmbInFeatureClass.Text == null)
     {
         MessageBox.Show("You must specify a sediment polygon.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     //Need to add the progress form
     this.Visible = false;
     this.Refresh();
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false);
     rd.addMessage("Creating sediment by arrival time table");
     rd.stepPGBar(10);
     rd.Refresh();
     rd.Show();
     DateTime dt1 = DateTime.Now;
     try
     {
         rd.addMessage("Setting up directories...");
         rd.Refresh();
         gSed.ResultsDir = resultsDir;
         rd.stepPGBar(10);
         rd.addMessage("Output directroy = " + gSed.GraphDir+ "\nCreating Sediment Rasters...");
         rd.Refresh();
         gSed.RunningProcessForm = rd;
         gSed.StreamPolygon = ftrDic[cmbInFeatureClass.Text];
         rd.stepPGBar(10);
         rd.addMessage("Summarizing sediment by arrival time. This may take a while...");
         rd.Refresh();
         gSed.sumSedimentValues();
     }
     catch (Exception ex)
     {
         rd.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt1);
         string totalTime = "Processing took " + ts.TotalMinutes + " minutes to complete";
         rd.addMessage(totalTime);
         rd.addMessage("Finished making table");
         rd.stepPGBar(100);
         rd.enableClose();
         this.Close();
     }
 }
コード例 #18
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            if (!System.IO.Directory.Exists(resultsDir))
            {
                MessageBox.Show("You must select both a OpFuels Project and Scenerio before you can execute.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //gSed.CellSize = System.Convert.ToDouble(nudCellSize.Value);
            //gSed.ArrivalClass = (graphSedimentByArivalTime.ArrivalClasses)Enum.Parse(typeof(graphSedimentByArivalTime.ArrivalClasses),cmbArrival.Text);
            gSed.CreateIntermediateRasters = chbIntermidiate.Checked;
            gSed.CreateCoreRasters         = chbCore.Checked;
            gSed.FlameLength = System.Convert.ToDouble(nudFlameLength.Value);
            if (cmbF10.Text != "")
            {
                gSed.Fine10Field = cmbF10.Text;
            }
            else
            {
                MessageBox.Show("You must specify a NA10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbF50.Text != "")
            {
                gSed.Fine50Field = cmbF50.Text;
            }
            else
            {
                MessageBox.Show("You must specify a NA50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbT10.Text != "")
            {
                gSed.T1_Fine_10Field = cmbT10.Text;
            }
            else
            {
                MessageBox.Show("You must specify a TR10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbT50.Text != "")
            {
                gSed.T1_Fine_50Field = cmbT50.Text;
            }
            else
            {
                MessageBox.Show("You must specify a TR50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbHSF10.Text != "")
            {
                gSed.HSF10Field = cmbHSF10.Text;
            }
            else
            {
                MessageBox.Show("You must specify a HS10 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbHSF50.Text != "")
            {
                gSed.HSF50Field = cmbHSF50.Text;
            }
            else
            {
                MessageBox.Show("You must specify a HS50 field value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cmbInFeatureClass.Text == "" || cmbInFeatureClass.Text == null)
            {
                MessageBox.Show("You must specify a sediment polygon.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Need to add the progress form
            this.Visible = false;
            this.Refresh();
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false);
            rd.addMessage("Creating sediment by arrival time table");
            rd.stepPGBar(10);
            rd.Refresh();
            rd.Show();
            DateTime dt1 = DateTime.Now;

            try
            {
                rd.addMessage("Setting up directories...");
                rd.Refresh();
                gSed.ResultsDir = resultsDir;
                rd.stepPGBar(10);
                rd.addMessage("Output directroy = " + gSed.GraphDir + "\nCreating Sediment Rasters...");
                rd.Refresh();
                gSed.RunningProcessForm = rd;
                gSed.StreamPolygon      = ftrDic[cmbInFeatureClass.Text];
                rd.stepPGBar(10);
                rd.addMessage("Summarizing sediment by arrival time. This may take a while...");
                rd.Refresh();
                gSed.sumSedimentValues();
            }
            catch (Exception ex)
            {
                rd.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2       = DateTime.Now;
                TimeSpan ts        = dt2.Subtract(dt1);
                string   totalTime = "Processing took " + ts.TotalMinutes + " minutes to complete";
                rd.addMessage(totalTime);
                rd.addMessage("Finished making table");
                rd.stepPGBar(100);
                rd.enableClose();
                this.Close();
            }
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string tblStr = cmbTable.Text;
            if (tblStr == "")
            {
                MessageBox.Show("You must specify a Table or Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbFields.Items.Count < 1 )
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbStats.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on summary statistic", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            rasterUtil.localType[] statLst = new rasterUtil.localType[lsbStats.Items.Count];
            ITable tbl = tblDic[tblStr];
            string[] fldsArr = lsbFields.Items.Cast<string>().ToArray();
            for (int i = 0; i < lsbStats.Items.Count; i++)
            {
                statLst[i] = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType),lsbStats.Items[i].ToString());
            }
            this.Visible = false;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Summarizing Fields. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                featureUtil ftrUtil = new featureUtil();
                ftrUtil.summarizeAcrossFields(tbl, fldsArr, statLst, qWhere);
                if (mp != null && addToMap)
                {

                    rp.Refresh();

                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
        public void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm = txtOutNm.Text;
            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbRaster.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();
            for (int i = 0; i < lsbRaster.Items.Count; i++)
            {
                rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]);

            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Building " + mStr + " Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                if (this.Text == "Create Composite Raster")
                {
                    outraster = rsUtil.createRaster(rsUtil.compositeBandFunction(rsBc));
                }
                else
                {

                    outraster = rsUtil.createRaster(rsUtil.calcCombineRasterFunction(rsBc));
                }
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name = rstNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished " + mStr + " Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #21
0
        private void btnSample_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string rstNm    = cmbRaster.Text;

            if (smpFtrNm == null || smpFtrNm == "" || rstNm == "" || rstNm == null)
            {
                MessageBox.Show("sample location or raster are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IFeatureClass ftrCls = ftrDic[smpFtrNm];
            string        fldNm  = cmbBandField.Text;

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Sampling layers");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();
            DateTime dt1 = DateTime.Now;

            try
            {
                if (rstDic.Keys.Contains(rstNm))
                {
                    if (ftrCls.Fields.FindField(fldNm) == -1)
                    {
                        fldNm = null;
                    }
                    rsUtil.sampleRaster(ftrCls, rstDic[rstNm], rstNm, fldNm);
                }
                else
                {
                    List <IField> flds       = new List <IField>();
                    IFeatureClass ftrClsSamp = ftrDic[rstNm];
                    int           fldIndex   = ftrClsSamp.Fields.FindField(fldNm);
                    if (fldIndex == -1)
                    {
                        fldNm = null;
                    }
                    else
                    {
                        flds.Add(ftrClsSamp.Fields.get_Field(fldIndex));
                    }
                    if (fldNm == null)
                    {
                        for (int f = 0; f < ftrClsSamp.Fields.FieldCount; f++)
                        {
                            IField fld = ftrClsSamp.Fields.get_Field(f);
                            if (fld.Type == esriFieldType.esriFieldTypeDouble || fld.Type == esriFieldType.esriFieldTypeInteger || fld.Type == esriFieldType.esriFieldTypeSingle || fld.Type == esriFieldType.esriFieldTypeSmallInteger)
                            {
                                flds.Add(fld);
                            }
                            else
                            {
                            }
                        }
                    }
                    ftrUtil.sampleFeatureClass(ftrCls, ftrDic[rstNm], flds.ToArray());
                }
                DateTime dt2     = DateTime.Now;
                TimeSpan ts      = dt2.Subtract(dt1);
                string   prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
        public void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm = cmbInRaster1.Text;
            string outNm = txtOutName.Text;
            if ( rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a raster layer selected and a valid value", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNm == "" || outNm == null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Transforming Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                IRaster rst = rstDic[rstNm];
                switch (sType)
                {
                    case rasterUtil.surfaceType.SLOPE:
                        outraster = rsUtil.returnRaster(rsUtil.calcSlopeFunction(rst));
                        break;
                    case rasterUtil.surfaceType.ASPECT:
                        outraster = rsUtil.createRaster(rsUtil.calcAspectFunction(rst));
                        break;
                    case rasterUtil.surfaceType.EASTING:
                        outraster = rsUtil.createRaster(rsUtil.calcEastWestFunction(rst));
                        break;
                    case rasterUtil.surfaceType.NORTHING:
                        outraster = rsUtil.createRaster(rsUtil.calcNorthSouthFunction(rst));
                        break;
                    default:
                        outraster = rsUtil.createRaster(rsUtil.flipRasterFunction(rst));
                        break;
                }

                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername = outNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Setting Values Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #23
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm       = cmbRaster.Text;
            string inFocalStat    = cmbFocalStat.Text;
            string windowType     = cmbWindowType.Text;
            string landMetricType = cmbMetric.Text;
            string outNmRst       = txtOutName.Text;
            int    clms           = System.Convert.ToInt32(nudColumns.Value);
            int    rws            = System.Convert.ToInt32(nudRows.Value);

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inFocalStat == "" || inFocalStat == null)
            {
                MessageBox.Show("You must specify an Focal Statistic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (windowType == "" || windowType == null)
            {
                MessageBox.Show("You must select a widow type from dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (landMetricType == "" || landMetricType == null)
            {
                MessageBox.Show("You must select a metric type from dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IRaster rs1   = rstDic[inRst1Nm];
            IRaster outRs = null;

            rasterUtil.windowType wdType = (rasterUtil.windowType)Enum.Parse(typeof(rasterUtil.windowType), windowType);

            rasterUtil.landscapeType lcType = (rasterUtil.landscapeType)Enum.Parse(typeof(rasterUtil.landscapeType), landMetricType);
            rasterUtil.focalType     fcType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), inFocalStat);
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                if (wdType == rasterUtil.windowType.CIRCLE)
                {
                    outRs = rsUtil.createRaster(rsUtil.calcLandscapeFunction(rs1, clms, fcType, lcType));
                }
                else
                {
                    outRs = rsUtil.createRaster(rsUtil.calcLandscapeFunction(rs1, clms, rws, fcType, lcType));
                }
                outraster     = outRs;
                outrastername = outNmRst;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Estimating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = OutRasterName;
                    rsLyr.Visible = false;
                    mp.AddLayer(rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Landscape Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnClip_Click(object sender, EventArgs e)
 {
     string rstNm = cmbInRaster1.Text;
     string outNm = txtOutName.Text;
     int rws = System.Convert.ToInt32(nudRows.Value);
     int clms = System.Convert.ToInt32(nudColumns.Value);
     if (rstNm == "" || rstNm == null)
     {
         MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (outNm == "" || outNm == null)
     {
         MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     List<double> kernalLst = new List<double>();
     for (int i = 0; i < dgvKernal.ColumnCount; i++)
     {
         for (int j = 0; j < dgvKernal.RowCount; j++)
         {
             object vlo = dgvKernal[i, j].Value;
             double vl = 0;
             if (DBNull.Value.Equals(vlo))
             {
                 vl = 0;
             }
             else
             {
                 vl = System.Convert.ToDouble(dgvKernal[i, j].Value);
             }
             kernalLst.Add(vl);
             //Console.WriteLine(vl.ToString());
         }
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Creating Raster. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     try
     {
         IRaster rst = rstDic[rstNm];
         outraster = rsUtil.returnRaster(rsUtil.convolutionRasterFunction(rst,clms,rws,kernalLst.ToArray()));
         if (mp != null && addToMap)
         {
             rp.addMessage("Calculating Statistics...");
             rp.Show();
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
             rstLyr.CreateFromRaster(outraster);
             rstLyr.Name = outNm;
             rstLyr.Visible = false;
             mp.AddLayer(rstLyr);
         }
         outrastername = outNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Convolution Analysis" + t);
         rp.enableClose();
         this.Close();
     }
 }
コード例 #25
0
        private void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm   = cmbInRaster1.Text;
            string outNm   = txtOutName.Text;
            string pixelNm = cmbPixel.Text;

            if (pixelNm == "" || pixelNm == null || rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNm == "" || outNm == null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Rescaling Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            this.Visible = false;
            try
            {
                IFunctionRasterDataset rst   = frmHlp.FunctionRasterDictionary[rstNm];
                rstPixelType           pType = (rstPixelType)Enum.Parse(typeof(rstPixelType), pixelNm);
                if (stats == null)
                {
                    outraster = rsUtil.reScaleRasterFunction(rst, pType, esriRasterStretchType.esriRasterStretchMinimumMaximum);
                }
                else
                {
                    double[] min  = new double[rst.RasterInfo.BandCount];
                    double[] max  = new double[rst.RasterInfo.BandCount];
                    double[] mean = new double[rst.RasterInfo.BandCount];
                    double[] std  = new double[rst.RasterInfo.BandCount];
                    for (int i = 0; i < rst.RasterInfo.BandCount; i++)
                    {
                        min[i]  = stats[i][0];
                        max[i]  = stats[i][1];
                        mean[i] = stats[i][2];
                        std[i]  = stats[i][3];
                    }
                    //MessageBox.Show(String.Join(",", (from double d in stats[0] select d.ToString()).ToArray()));
                    outraster = rsUtil.reScaleRasterFunction(rst, pType, esriRasterStretchType.esriRasterStretchMinimumMaximum, min, max, mean, std);
                }
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromDataset((IRasterDataset)outraster);
                    rstLyr.Name    = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = outNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Scalling Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnClip_Click(object sender, EventArgs e)
        {
            string ftrNm = cmbSampleFeatureClass.Text;
            string rstNm = cmbRaster.Text;
            string outNm = txtOutRasterName.Text;
            bool chErase = chbErase.Checked;
            esriRasterClippingType clType = esriRasterClippingType.esriRasterClippingOutside;
            if (ftrNm == "" || ftrNm == null || rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a polygon and raster layer selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if(outNm==""||outNm==null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if(chErase)
            {
                clType= esriRasterClippingType.esriRasterClippingInside;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Clipping Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                IRaster rst = rstDic[rstNm];
                IFeatureClass ftrCls = ftrDic[ftrNm];
                IGeometry geo = geoUtil.createGeometry(ftrCls);
                IFunctionRasterDataset outraster = rsUtil.clipRasterFunction(rst, geo, clType);
                if (mp != null&&addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromDataset((IRasterDataset)outraster);
                    rstLyr.Name = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername = outNm;
                this.DialogResult = DialogResult.OK;

            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Clipping Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #27
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm     = txtOutNm.Text;
            float  intercept = System.Convert.ToSingle(nudIntercept.Value);

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dgvRasterSlopes.Rows.Count < 1)
            {
                MessageBox.Show("You must select at least one Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IRasterBandCollection rsBc   = new RasterClass();
            List <float>          slopes = new List <float>();

            slopes.Add(intercept);
            for (int i = 0; i < dgvRasterSlopes.Rows.Count; i++)
            {
                rsBc.AppendBands((IRasterBandCollection)rstDic[dgvRasterSlopes[0, i].Value.ToString()]);
                object vl = dgvRasterSlopes[1, i].Value;
                if (Convert.IsDBNull(vl))
                {
                    vl = 0;
                }
                slopes.Add(System.Convert.ToSingle(vl));
            }
            IFunctionRasterDataset comp    = rsUtil.compositeBandFunction(rsBc);
            List <float[]>         fslopes = new List <float[]>();

            fslopes.Add(slopes.ToArray());
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Transforming Rasters. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                outraster = rsUtil.returnRaster(rsUtil.calcRegressFunction(comp, fslopes));
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = rstNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Transforming Rasters" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #28
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm    = cmbInRaster1.Text;
            string txtNoDataVl = txtNodata.Text;
            int    noVl        = 0;

            if (!Int32.TryParse(txtNoDataVl, out noVl))
            {
                noVl = 0;
            }
            string outNmRst = txtOutName.Text;

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRaster rs1 = rstDic[inRst1Nm];

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.addMessage("Calculating Statistics...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            rp.Refresh();
            try
            {
                outraster     = rsUtil.returnRaster(rsUtil.setNullValue(rs1, noVl));
                outrastername = outNmRst;
                int bCnt = ((IRasterBandCollection)outraster).Count;
                if (mp != null && aM)
                {
                    //rsUtil.calcStatsAndHist(((IRaster2)outRs).RasterDataset);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished setting null" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbInRaster1.Text;
            string inRst2Nm = cmbInRaster2.Text;
            string opNm = cmbProcess.Text;
            string outNmRst = txtOutName.Text;
            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (inRst2Nm == "" || inRst2Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (opNm == "" || opNm == null)
            {
                MessageBox.Show("You must select a process from the dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object rs1,rs2;
            if(rstDic.ContainsKey(inRst1Nm))
            {
                rs1 = rstDic[inRst1Nm];
            }
            else if(rsUtil.isNumeric(inRst1Nm))
            {
                rs1 = inRst1Nm;

            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if(rstDic.ContainsKey(inRst2Nm))
            {
                rs2 = rstDic[inRst2Nm];
            }
            else if(rsUtil.isNumeric(inRst2Nm))
            {
                rs2 = inRst2Nm;

            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            rasterUtil.logicalType op = oprDic[opNm];
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                switch (op)
                {
                    case rasterUtil.logicalType.GT:
                        outraster = rsUtil.returnRaster(rsUtil.calcGreaterFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.LT:
                        outraster = rsUtil.returnRaster(rsUtil.calcLessFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.GE:
                        outraster = rsUtil.returnRaster(rsUtil.calcGreaterEqualFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.LE:
                        outraster = rsUtil.returnRaster(rsUtil.calcLessEqualFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.EQ:
                        outraster = rsUtil.returnRaster(rsUtil.calcEqualFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.AND:
                        outraster = rsUtil.returnRaster(rsUtil.calcAndFunction(rs1, rs2));
                        break;
                    case rasterUtil.logicalType.OR:
                        outraster = rsUtil.returnRaster(rsUtil.calcOrFunction(rs1, rs2));
                        break;
                    default:
                        break;
                }
                outrastername = outNmRst;
                if (mp != null && aM)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Logical Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #30
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string strataStr = cmbStrata.Text;
            string standsStr = cmbStands.Text;

            if (strataStr == "")
            {
                MessageBox.Show("You must specify a Stratification Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (standsStr == "")
            {
                MessageBox.Show("You must specify a Stands Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbFields.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IFeatureClass strataCls = ftrDic[strataStr];
            IFeatureClass standsCls = ftrDic[standsStr];

            string[] fldsArr = lsbFields.Items.Cast <string>().ToArray();
            this.Visible = false;


            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Summarizing Fields. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                featureUtil ftrUtil = new featureUtil();
                ftrUtil.weightFieldValuesByAreaLength(strataCls, fldsArr, standsCls, chbLength.Checked);
                if (mp != null && addToMap)
                {
                    rp.Refresh();
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #31
0
        public void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm = cmbInRaster1.Text;
            string outNm = txtOutName.Text;

            if (rstNm == "" || rstNm == null)
            {
                MessageBox.Show("You must have a raster layer selected and a valid value", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNm == "" || outNm == null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Transforming Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                IRaster rst = rstDic[rstNm];
                switch (sType)
                {
                case rasterUtil.surfaceType.SLOPE:
                    outraster = rsUtil.returnRaster(rsUtil.calcSlopeFunction(rst));
                    break;

                case rasterUtil.surfaceType.ASPECT:
                    outraster = rsUtil.createRaster(rsUtil.calcAspectFunction(rst));
                    break;

                case rasterUtil.surfaceType.EASTING:
                    outraster = rsUtil.createRaster(rsUtil.calcEastWestFunction(rst));
                    break;

                case rasterUtil.surfaceType.NORTHING:
                    outraster = rsUtil.createRaster(rsUtil.calcNorthSouthFunction(rst));
                    break;

                default:
                    outraster = rsUtil.createRaster(rsUtil.flipRasterFunction(rst));
                    break;
                }

                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = outNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Setting Values Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #32
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbRaster.Text;

            double newCellSize = 0;
            string outNmRst    = txtOutName.Text;

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (rsUtil.isNumeric(txtCellSize.Text))
            {
                newCellSize = System.Convert.ToDouble(txtCellSize.Text);
            }
            else
            {
                MessageBox.Show("You must specify a numeric cell size", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IRaster rs1   = rstDic[inRst1Nm];
            IRaster outRs = null;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                outRs         = rsUtil.createRaster(rsUtil.reSampleRasterFunction(rs1, newCellSize));
                outraster     = outRs;
                outrastername = outNmRst;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = OutRasterName;
                    rsLyr.Visible = false;
                    mp.AddLayer(rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Resample Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string inRst1Nm = cmbInRaster1.Text;
     string inRst2Nm = cmbInRaster2.Text;
     string outNmRst = txtOutName.Text;
     int pChange = trbPercent.Value;
     if (inRst1Nm == "" || inRst1Nm == null)
     {
         MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (inRst2Nm == "" || inRst2Nm == null)
     {
         MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (outNmRst == "" || outNmRst == null)
     {
         MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRaster rs1 = rstDic[inRst1Nm];
     IRaster rs2 = rstDic[inRst2Nm];
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Creating Raster. This may take a while...");
     rp.addMessage("Calculating Statistics...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     rp.Refresh();
     normalization nm = new normalization(rsUtil.createIdentityRaster(rs1), rsUtil.createIdentityRaster(rs2), pChange, rsUtil);
     try
     {
         double[][] coef = nm.Coefficients;
         outraster = rsUtil.createRaster(nm.OutRaster);
         outrastername = outNmRst;
         int bCnt = ((IRasterBandCollection)outraster).Count;
         for (int i = 0; i < bCnt; i++)
         {
             double[] intSlp  = coef[i];
             double intercept = intSlp[0];
             double slope = intSlp[1];
             double r2 = intSlp[2];
             rp.addMessage("R2, Intercept, Slope (" + (i+1).ToString() + ") = " + r2.ToString() + ", " + intercept.ToString() + ", " + slope.ToString());
         }
         if (mp != null && aM)
         {
             //rsUtil.calcStatsAndHist(((IRaster2)outRs).RasterDataset);
             IRasterLayer rsLyr = new RasterLayerClass();
             rsLyr.CreateFromRaster(outraster);
             rsLyr.Name = outrastername;
             rsLyr.Visible = false;
             mp.AddLayer((ILayer)rsLyr);
         }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Normalizing Image" + t);
         rp.enableClose();
         this.Close();
     }
 }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string zNm = cmbZoneRaster.Text;
            string vNm = cmbValueRaster.Text;
            string zFld = cmbZoneField.Text;
            string oTbl = txtTableName.Text;
            if (zNm == null || zNm == "")
            {
                MessageBox.Show("You must specify a zone layer","No Zone",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if(ftrDic.ContainsKey(zNm))
            {
                if(zFld==""||zFld==null)
                {
                    MessageBox.Show("You must specify a field for the feature class","No Zone",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
            }
            if (vNm == null || vNm == "")
            {
                MessageBox.Show("You must specify a value raster","No Value",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (oTbl == null || oTbl == "")
            {
                MessageBox.Show("You must specify an output table name","No Value",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (lsbStats.Items.Count < 1&& !chbClassCounts.Checked)
            {
                MessageBox.Show("You must select at least on Zonal Statistic or check class count", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List<rasterUtil.zoneType> rsLst = new List<rasterUtil.zoneType>();
            for (int i = 0; i < lsbStats.Items.Count; i++)
            {
                rsLst.Add((rasterUtil.zoneType)Enum.Parse(typeof(rasterUtil.zoneType),lsbStats.Items[i].ToString()));
            }
            this.Visible = false;
            IRaster vRs = rstDic[vNm];

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Calculating Zonal Statistics. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            rp.Refresh();
            Statistics.ModelHelper.runProgressBar("Calculating Zonal Stats");
            try
            {
                ITable outTbl = null;
                if(rstDic.ContainsKey(zNm))
                {
                    IRaster zRs = rstDic[zNm];
                    outTbl = rsUtil.zonalStats(zRs,vRs,oTbl,rsLst.ToArray(),rp,chbClassCounts.Checked);
                }
                else
                {
                    rp.addMessage("Running Zonal Statistics on feature class...");
                    rp.Refresh();
                    IFeatureClass zFtr = ftrDic[zNm];
                    outTbl = rsUtil.zonalStats(zFtr,zFld,vRs,oTbl,rsLst.ToArray(),rp,chbClassCounts.Checked);
                }
                if (mp != null&&addToMap)
                {

                    rp.Refresh();

                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Zonal Stats" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #35
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string ptblStr = cmbParent.Text;

            if (ptblStr == "")
            {
                MessageBox.Show("You must specify a Parent Table or Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string plink = cmbPLink.Text;

            if (String.IsNullOrEmpty(plink))
            {
                MessageBox.Show("You must specify a Parent Link Field", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string rtblStr = cmbChild.Text;

            if (rtblStr == "")
            {
                MessageBox.Show("You must specify a Child Table or Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string rlink = cmbCLink.Text;

            if (String.IsNullOrEmpty(rlink))
            {
                MessageBox.Show("You must specify a Child Link Field", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbFields.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbStats.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on summary statistic", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            rasterUtil.focalType[] statLst = new rasterUtil.focalType[lsbStats.Items.Count];
            ITable ptbl = tblDic[ptblStr];
            ITable rtbl = tblDic[rtblStr];

            string[] fldsArr   = lsbFields.Items.Cast <string>().ToArray();
            string[] groupFlds = lsbGroup.Items.Cast <string>().ToArray();
            for (int i = 0; i < lsbStats.Items.Count; i++)
            {
                statLst[i] = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), lsbStats.Items[i].ToString());
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Summarizing Fields. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                featureUtil ftrUtil = new featureUtil();
                ftrUtil.summarizeRelatedTable(ptbl, rtbl, plink, rlink, fldsArr, groupFlds, statLst, pWhere, rWhere);
                if (mp != null && addToMap)
                {
                    rp.Refresh();
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #36
0
        private void createRaster()
        {
            string rstNm    = cmbRaster.Text;
            string rstOut   = mtbOutName.Text.Trim();
            string windType = cmbWindowType.Text;
            string windDir  = cmbDirections.Text;
            string glcmType = cmbGlcmTypes.Text;
            int    clms     = System.Convert.ToInt32(nudColumns.Value);
            int    rows     = System.Convert.ToInt32(nudRows.Value);
            List <rasterUtil.glcmMetric> glcmArr = new List <rasterUtil.glcmMetric>();

            if (rstNm == "" || rstNm == null || rstOut == "" || rstOut == null)
            {
                MessageBox.Show("You must have both a raster and output name specified to use this tool!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (windType == null || windType == "" || windDir == "" || windDir == null)
            {
                MessageBox.Show("Window Type and Direction are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (glcmType == null || glcmType == "" || glcmType == "" || glcmType == null)
            {
                MessageBox.Show("Glcm Type is not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool horz = true;

            rasterUtil.windowType wt = (rasterUtil.windowType)Enum.Parse(typeof(rasterUtil.windowType), windType);
            rasterUtil.glcmMetric gm = (rasterUtil.glcmMetric)Enum.Parse(typeof(rasterUtil.glcmMetric), glcmType);
            if (windDir.ToUpper() != "HORIZONTAL")
            {
                horz = false;
            }
            bool radius = false;

            if (wt != rasterUtil.windowType.RECTANGLE)
            {
                radius = true;
            }

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog((perm == false));
            System.DateTime t1 = System.DateTime.Now;
            rp.addMessage("Start date and time = " + t1.Month.ToString() + "\\" + t1.Day.ToString() + "\\" + t1.Year.ToString() + " " + t1.Hour.ToString() + ":" + t1.Minute.ToString() + ":" + t1.Second.ToString());
            rp.addMessage("Creating the following " + windDir + " GLCM surfaces for the specified Raster:");
            rp.stepPGBar(15);
            if (perm)
            {
                rp.Show();
            }
            rp.Refresh();
            rp.TopMost = true;
            foreach (rasterUtil.glcmMetric g in glcmArr)
            {
                rp.addMessage("\t" + g.ToString());
            }
            rp.Refresh();
            IRaster inRs = rstDic[rstNm];

            try
            {
                if (radius)
                {
                    rst = rstUtil.createRaster(rstUtil.fastGLCMFunction(inRs, clms, horz, gm));
                }
                else
                {
                    rst = rstUtil.createRaster(rstUtil.fastGLCMFunction(inRs, clms, rows, horz, gm));
                }
                if (mp != null && perm)
                {
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rstUtil.calcStatsAndHist(rst);
                    rsLyr.CreateFromRaster(rst);
                    rsLyr.Name    = rstOut;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                System.DateTime t2 = System.DateTime.Now;
                rp.addMessage("End date and time = " + t2.Month.ToString() + "\\" + t2.Day.ToString() + "\\" + t2.Year.ToString() + " " + t2.Hour.ToString() + ":" + t2.Minute.ToString() + ":" + t2.Second.ToString());
                rp.stepPGBar(100);
                rp.Refresh();
                oNm = rstOut;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.enableClose();
                this.Close();
            }
            return;
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbRaster.Text;
            string inFocalStat = cmbFocalStat.Text;

            string outNmRst = txtOutName.Text;
            int clms = System.Convert.ToInt32(nudColumns.Value);

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (inFocalStat == "" || inFocalStat == null)
            {
                MessageBox.Show("You must specify an Aggregation Statistic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IRaster rs1 = rstDic[inRst1Nm];
            IRaster outRs = null;
            rasterUtil.focalType fcType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), inFocalStat);
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {

                outRs = rsUtil.createRaster(rsUtil.calcAggregationFunction(rs1,clms,fcType));

                outraster = outRs;
                outrastername = outNmRst;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name = OutRasterName;
                    rsLyr.Visible = false;
                    mp.AddLayer(rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Aggregation Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnCreateSamples_Click(object sender, EventArgs e)
        {
            string rst = cmbRst.Text;
            string oWks = txtOutWorkspace.Text;
            string sNm = txtSampleName.Text;
            string mPath = txtSampleSize.Text;
            int[] numSample = null;
            double prop = System.Convert.ToDouble(nudProp.Value);
            double alpha = System.Convert.ToDouble(nudAlpha.Value);
            if (rsUtil.isNumeric(mPath))
            {
                numSample = new int[]{System.Convert.ToInt32(mPath)};
            }
            else
            {
                numSample = esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxCluster(mPath, prop, alpha);
            }
            if (rst == null || rst == "" || oWks == null || oWks == "")
            {
                MessageBox.Show("You must specify a raster, an output workspace, and a output file name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            IRaster rs = rstDic[rst];
            IRasterBandCollection rsBc = (IRasterBandCollection)rs;
            IDataset ds = (IDataset)rsBc.Item(0).RasterDataset;
            this.Visible = false;
            this.Refresh();
            RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.Show();
            rp.stepPGBar(20);
            DateTime ds1 = DateTime.Now;
            try
            {
                IFeatureClass ftrCls = null;
                if (strata)
                {
                    rp.addMessage("Creating random stratified sample. This could take a while...");
                    rp.stepPGBar(10);
                    rp.Refresh();
                    ftrCls = rsUtil.createRandomSampleLocationsByClass(geoUtil.OpenWorkSpace(oWks), rs, numSample, 1, sNm);

                }
                else
                {
                    rp.addMessage("Creating random sample. This could take a while...");
                    rp.stepPGBar(10);
                    rp.Refresh();
                    ftrCls =rsUtil.createRandomSampleLocations(geoUtil.OpenWorkSpace(oWks), rs, numSample[0],sNm);
                }
                if (mp!=null)
                {
                    rp.addMessage("Adding Samples to the map");
                    rp.stepPGBar(20);
                    rp.Refresh();
                    IFeatureLayer fLyer = new FeatureLayerClass();
                    fLyer.FeatureClass = ftrCls;
                    fLyer.Name = sNm;
                    fLyer.Visible = true;
                    mp.AddLayer(fLyer);
                }

            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime ds2 = DateTime.Now;
                TimeSpan ts = ds2.Subtract(ds1);
                rp.stepPGBar(100);
                string tsSpan = "Process took a total of " + ts.TotalMinutes.ToString() + " minutes to finish";
                rp.addMessage("Finished creating samples");
                rp.addMessage(tsSpan);
                rp.enableClose();
                //rp.TopLevel = false;
                this.Close();
            }
        }
コード例 #39
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string zNm  = cmbZoneRaster.Text;
            string vNm  = cmbValueRaster.Text;
            string zFld = cmbZoneField.Text;
            string oTbl = txtTableName.Text;

            if (zNm == null || zNm == "")
            {
                MessageBox.Show("You must specify a zone layer", "No Zone", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (ftrDic.ContainsKey(zNm))
            {
                if (zFld == "" || zFld == null)
                {
                    MessageBox.Show("You must specify a field for the feature class", "No Zone", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (vNm == null || vNm == "")
            {
                MessageBox.Show("You must specify a value raster", "No Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (oTbl == null || oTbl == "")
            {
                MessageBox.Show("You must specify an output table name", "No Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbStats.Items.Count < 1 && !chbClassCounts.Checked)
            {
                MessageBox.Show("You must select at least on Zonal Statistic or check class count", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <rasterUtil.zoneType> rsLst = new List <rasterUtil.zoneType>();

            for (int i = 0; i < lsbStats.Items.Count; i++)
            {
                rsLst.Add((rasterUtil.zoneType)Enum.Parse(typeof(rasterUtil.zoneType), lsbStats.Items[i].ToString()));
            }
            this.Visible = false;
            IRaster vRs = rstDic[vNm];

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Calculating Zonal Statistics. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            rp.Refresh();
            Statistics.ModelHelper.runProgressBar("Calculating Zonal Stats");
            try
            {
                ITable outTbl = null;
                if (rstDic.ContainsKey(zNm))
                {
                    IRaster zRs = rstDic[zNm];
                    outTbl = rsUtil.zonalStats(zRs, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                }
                else
                {
                    rp.addMessage("Running Zonal Statistics on feature class...");
                    rp.Refresh();
                    IFeatureClass zFtr = ftrDic[zNm];
                    outTbl = rsUtil.zonalStats(zFtr, zFld, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                }
                if (mp != null && addToMap)
                {
                    rp.Refresh();
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Zonal Stats" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbInRaster1.Text;
            string inRst2Nm = cmbInRaster2.Text;
            string inRst3Nm = cmbInRaster3.Text;
            string outNmRst = txtOutName.Text;
            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (inRst2Nm == "" || inRst2Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inRst3Nm == "" || inRst3Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 3 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object rs1,rs2,rs3;
            if(rstDic.ContainsKey(inRst1Nm))
            {
                rs1 = rstDic[inRst1Nm];
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 1", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if(rstDic.ContainsKey(inRst2Nm))
            {
                rs2 = rstDic[inRst2Nm];
            }
            else if(rsUtil.isNumeric(inRst2Nm))
            {
                rs2 = inRst2Nm;

            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (rstDic.ContainsKey(inRst3Nm))
            {
                rs3 = rstDic[inRst3Nm];
            }
            else if (rsUtil.isNumeric(inRst3Nm))
            {
                rs3 = inRst3Nm;

            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 3 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                outraster = rsUtil.createRaster(rsUtil.conditionalRasterFunction(rs1, rs2, rs3));
                outrastername = outNmRst;
                if (mp != null && aM)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    //rsUtil.calcStatsAndHist(outraster);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Conditional Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #41
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbInRaster1.Text;
            string inRst2Nm = cmbInRaster2.Text;
            string opNm     = cmbProcess.Text;
            string outNmRst = txtOutName.Text;

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inRst2Nm == "" || inRst2Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (opNm == "" || opNm == null)
            {
                MessageBox.Show("You must select a process from the dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object rs1, rs2;

            if (rstDic.ContainsKey(inRst1Nm))
            {
                rs1 = rstDic[inRst1Nm];
            }
            else if (rsUtil.isNumeric(inRst1Nm))
            {
                rs1 = inRst1Nm;
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (rstDic.ContainsKey(inRst2Nm))
            {
                rs2 = rstDic[inRst2Nm];
            }
            else if (rsUtil.isNumeric(inRst2Nm))
            {
                rs2 = inRst2Nm;
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            rasterUtil.logicalType op = oprDic[opNm];
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                switch (op)
                {
                case rasterUtil.logicalType.GT:
                    outraster = rsUtil.returnRaster(rsUtil.calcGreaterFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.LT:
                    outraster = rsUtil.returnRaster(rsUtil.calcLessFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.GE:
                    outraster = rsUtil.returnRaster(rsUtil.calcGreaterEqualFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.LE:
                    outraster = rsUtil.returnRaster(rsUtil.calcLessEqualFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.EQ:
                    outraster = rsUtil.returnRaster(rsUtil.calcEqualFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.AND:
                    outraster = rsUtil.returnRaster(rsUtil.calcAndFunction(rs1, rs2));
                    break;

                case rasterUtil.logicalType.OR:
                    outraster = rsUtil.returnRaster(rsUtil.calcOrFunction(rs1, rs2));
                    break;

                default:
                    break;
                }
                outrastername = outNmRst;
                if (mp != null && aM)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Logical Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = txtOutNm.Text;
     esriMosaicMethod mMethod = (esriMosaicMethod)Enum.Parse(typeof(esriMosaicMethod),cmbMethod.Text);
     rstMosaicOperatorType mType = (rstMosaicOperatorType)Enum.Parse(typeof(rstMosaicOperatorType), cmbType.Text);
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify a output name","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (outWks == null)
     {
         MessageBox.Show("You must specify an output workspace", "No Workspace", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (lsbRaster.Items.Count < 1)
     {
         MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     List<IRaster> rsLst = new List<IRaster>();
     for (int i = 0; i < lsbRaster.Items.Count; i++)
     {
         rsLst.Add(rstDic[lsbRaster.Items[i].ToString()]);
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Building Mosaic Raster. This may take a while...");
     rp.stepPGBar(10);
     rp.Show();
     rp.TopMost = true;
     if (chbOverview.Checked)
     {
         rp.addMessage("Building overviews will take additional time...");
     }
     try
     {
         outraster = rsUtil.mosaicRastersFunction(outWks,rstNm,rsLst.ToArray(),mMethod,mType,chbFootprint.Checked,chbBoundary.Checked,chbSeamlines.Checked,chbOverview.Checked);
         rp.addMessage("Adding mosaic dataset to the map");
         if (mp != null&&addToMap)
         {
             rp.Show();
             rp.Refresh();
             IMosaicLayer rstLyr = new MosaicLayerClass();
             rstLyr.CreateFromMosaicDataset((IMosaicDataset)((IRaster2)outraster).RasterDataset);
             mp.AddLayer((ILayer)rstLyr);
         }
         outrastername = rstNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Mosaic Raster" + t);
         rp.enableClose();
         this.Close();
     }
 }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string strataStr = cmbStrata.Text;
            string standsStr = cmbStands.Text;
            if (strataStr == "")
            {
                MessageBox.Show("You must specify a Stratification Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (standsStr == "")
            {
                MessageBox.Show("You must specify a Stands Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbFields.Items.Count < 1 )
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IFeatureClass strataCls = ftrDic[strataStr];
            IFeatureClass standsCls = ftrDic[standsStr];
            string[] fldsArr = lsbFields.Items.Cast<string>().ToArray();
            this.Visible = false;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Summarizing Fields. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                featureUtil ftrUtil = new featureUtil();
                ftrUtil.weightFieldValuesByAreaLength(strataCls,fldsArr,standsCls, chbLength.Checked);
                if (mp != null && addToMap)
                {

                    rp.Refresh();

                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string inRst1Nm = cmbInRaster1.Text;
     string txtNoDataVl = txtNodata.Text;
     int noVl = 0;
     if(!Int32.TryParse(txtNoDataVl,out noVl))noVl=0;
     string outNmRst = txtOutName.Text;
     if (inRst1Nm == "" || inRst1Nm == null)
     {
         MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (outNmRst == "" || outNmRst == null)
     {
         MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRaster rs1 = rstDic[inRst1Nm];
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Creating Raster. This may take a while...");
     rp.addMessage("Calculating Statistics...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     rp.Refresh();
     try
     {
         outraster = rsUtil.returnRaster(rsUtil.setNullValue(rs1,noVl));
         outrastername = outNmRst;
         int bCnt = ((IRasterBandCollection)outraster).Count;
         if (mp != null && aM)
         {
             //rsUtil.calcStatsAndHist(((IRaster2)outRs).RasterDataset);
             IRasterLayer rsLyr = new RasterLayerClass();
             rsLyr.CreateFromRaster(outraster);
             rsLyr.Name = outrastername;
             rsLyr.Visible = false;
             mp.AddLayer((ILayer)rsLyr);
         }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished setting null" + t);
         rp.enableClose();
         this.Close();
     }
 }
コード例 #45
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm  = txtOutNm.Text;
            string mdPath = txtOutputPath.Text;

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mdPath == null || mdPath == "")
            {
                MessageBox.Show("You must specify a model path", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbRaster.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < lsbRaster.Items.Count; i++)
            {
                rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]);
            }
            IFunctionRasterDataset frDset = rsUtil.compositeBandFunction(rsBc);

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Building Model Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                Statistics.ModelHelper br = new Statistics.ModelHelper(mdPath, rsUtil.createRaster(frDset), rsUtil);
                outraster = br.getRaster();
                if (mp != null && addToMap)
                {
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = rstNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Building Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #46
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string strataStr = cmbStrata.Text;
            string plotsStr  = cmbPlots.Text;
            string standsStr = cmbStands.Text;

            if (strataStr == null || strataStr == "")
            {
                MessageBox.Show("You must specify a Stratification layer", "No Zone", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (plotsStr == null || plotsStr == "")
            {
                MessageBox.Show("You must specify a plots layer", "No Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (lsbFields.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <IField> fldLst    = new List <IField>();
            IFeatureClass pltFtrCls = ftrDic[plotsStr];

            for (int i = 0; i < lsbFields.Items.Count; i++)
            {
                IField fld = pltFtrCls.Fields.get_Field(pltFtrCls.FindField(lsbFields.Items[i].ToString()));
                fldLst.Add(fld);
            }
            this.Visible = false;


            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Summarizing plots. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            //Statistics.ModelHelper.runProgressBar("Summarizing");
            try
            {
                IFeatureClass standFtrCls = null;
                if (ftrDic.ContainsKey(standsStr))
                {
                    standFtrCls = ftrDic[standsStr];
                }
                if (rstDic.ContainsKey(strataStr))
                {
                    rp.addMessage("Summarizing FIA plots using raster...");
                    IRaster strataRs = rstDic[strataStr];
                    IFunctionRasterDataset stratafDset = rsUtil.createIdentityRaster(strataRs);
                    //outTbl = rsUtil.zonalStats(zRs, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                    fiaIntegration.summarizeBiomassPolygon(pltFtrCls, fldLst.ToArray(), stratafDset, standFtrCls, geoUtil, rsUtil);
                }
                else
                {
                    rp.addMessage("Summarizing FIA plots using polygon");
                    rp.Refresh();
                    IFeatureClass strataFtr = ftrDic[strataStr];
                    //outTbl = rsUtil.zonalStats(zFtr, zFld, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                    fiaIntegration.summarizeBiomassPolygon(pltFtrCls, fldLst.ToArray(), strataFtr, standFtrCls, geoUtil);
                }
                if (mp != null && addToMap)
                {
                    rp.Refresh();
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #47
0
        private void btnCreateSamples_Click(object sender, EventArgs e)
        {
            string rst   = cmbRst.Text;
            string oWks  = txtOutWorkspace.Text;
            string sNm   = txtSampleName.Text;
            string mPath = txtSampleSize.Text;

            int[]  numSample = null;
            double prop      = System.Convert.ToDouble(nudProp.Value);
            double alpha     = System.Convert.ToDouble(nudAlpha.Value);

            if (rsUtil.isNumeric(mPath))
            {
                numSample = new int[] { System.Convert.ToInt32(mPath) };
            }
            else
            {
                numSample = esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxCluster(mPath, prop, alpha);
            }
            if (rst == null || rst == "" || oWks == null || oWks == "")
            {
                MessageBox.Show("You must specify a raster, an output workspace, and a output file name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            bool rsCheck = false;

            if (rstDic.Keys.Contains(rst))
            {
                rsCheck = true;
            }
            this.Visible = false;
            this.Refresh();
            RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.Show();
            rp.stepPGBar(20);
            DateTime ds1 = DateTime.Now;

            try
            {
                IFeatureClass ftrCls = null;
                if (strata)
                {
                    if (rsCheck)
                    {
                        IFunctionRasterDataset rs = rstDic[rst];
                        rp.addMessage("Creating random stratified sample. This could take a while...");
                        rp.stepPGBar(10);
                        rp.Refresh();
                        ftrCls = rsUtil.createRandomSampleLocationsByClass(geoUtil.OpenWorkSpace(oWks), rs, numSample, 1, sNm);
                    }
                    else
                    {
                        rp.addMessage("Cannot create stratified random sample for feature class. Use raster instead!");
                    }
                }
                else
                {
                    rp.addMessage("Creating random sample. This could take a while...");
                    rp.stepPGBar(10);
                    rp.Refresh();
                    if (rsCheck)
                    {
                        IFunctionRasterDataset rs = rstDic[rst];
                        ftrCls = rsUtil.createRandomSampleLocations(geoUtil.OpenWorkSpace(oWks), rs, numSample[0], sNm);
                    }
                    else
                    {
                        IFeatureClass inFtrCls = ftrDic[rst];
                        ftrCls = frmHlp.FeatureUtility.createRandomSample(inFtrCls, numSample[0], oWks + "\\" + sNm);
                    }
                }
                if (mp != null)
                {
                    rp.addMessage("Adding Samples to the map");
                    rp.stepPGBar(20);
                    rp.Refresh();
                    IFeatureLayer fLyer = new FeatureLayerClass();
                    fLyer.FeatureClass = ftrCls;
                    fLyer.Name         = sNm;
                    fLyer.Visible      = true;
                    mp.AddLayer(fLyer);
                }
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime ds2 = DateTime.Now;
                TimeSpan ts  = ds2.Subtract(ds1);
                rp.stepPGBar(100);
                string tsSpan = "Process took a total of " + ts.TotalMinutes.ToString() + " minutes to finish";
                rp.addMessage("Finished creating samples");
                rp.addMessage(tsSpan);
                rp.enableClose();
                //rp.TopLevel = false;
                this.Close();
            }
        }
コード例 #48
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string rstNm  = txtOutNm.Text;
            string funNm  = cmbFunction.Text;
            int    before = System.Convert.ToInt32(nudBefore.Value);
            int    after  = System.Convert.ToInt32(nudAfter.Value);

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbRaster.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (funNm == null || funNm == "")
            {
                MessageBox.Show("You must select at least on function", "No Function Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < lsbRaster.Items.Count; i++)
            {
                rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]);
            }
            IFunctionRasterDataset fdset = rsUtil.compositeBandFunction(rsBc);

            rasterUtil.localType op = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType), funNm);
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Calculating raster values. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                outraster = rsUtil.focalBandfunction(fdset, op, before, after);
                //rp.addMessage("Number of bands = " + ((IRasterBandCollection)outraster).Count);
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromDataset((IRasterDataset)outraster);
                    rstLyr.Name    = rstNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Creating Rasters" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnSample_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string rstNm = cmbRaster.Text;
            string fldNm = cmbBandField.Text;
            if (smpFtrNm == null || smpFtrNm == "" || rstNm == "" || rstNm == null)
            {
                MessageBox.Show("sample location or raster are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IFeatureClass ftrCls = ftrDic[smpFtrNm];
            if (ftrCls.Fields.FindField(fldNm) == -1)
            {
                fldNm = null;
            }
            this.Visible=false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Sampling raster");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();
            DateTime dt1 = DateTime.Now;
            try
            {

                rsUtil.sampleRaster(ftrCls, rstDic[rstNm],rstNm,fldNm);
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt1);
                string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);

            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnClip_Click(object sender, EventArgs e)
 {
     string rstNm = cmbInRaster1.Text;
     string outNm = txtOutName.Text;
     string visStr = cmbVis.Text;
     string irStr = cmbIr.Text;
     if (visStr == "" || visStr == null || rstNm == "" || rstNm == null||irStr==""||irStr==null)
     {
         MessageBox.Show("You must have a raster layer selected and a valid visual and ir band index value", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (outNm == "" || outNm == null)
     {
         MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     this.Visible = false;
     int visVl = System.Convert.ToInt32(visStr)-1;
     int irVl = System.Convert.ToInt32(irStr)-1;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Making Raster. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     try
     {
         IRaster rst = rstDic[rstNm];
         outraster = rsUtil.returnRaster(rsUtil.calcNDVIFunction(rst, visVl, irVl));
         if (mp != null && addToMap)
         {
             rp.addMessage("Calculating Statistics...");
             rp.Show();
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
             rstLyr.CreateFromRaster(outraster);
             rstLyr.Name = outNm;
             rstLyr.Visible = false;
             mp.AddLayer(rstLyr);
         }
         outrastername = outNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Making Raster" + t);
         rp.enableClose();
         this.Close();
     }
 }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = txtOutNm.Text;
     string mtypStr = cmbMergeType.Text;
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify a output name","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (lsbRaster.Items.Count < 1)
     {
         MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     IRaster[] rsArr = new IRaster[lsbRaster.Items.Count];
     for (int i = 0; i < lsbRaster.Items.Count; i++)
     {
         rsArr[i]=rstDic[lsbRaster.Items[i].ToString()];
     }
     if (mtypStr == null || mtypStr == "")
     {
         MessageBox.Show("You must specify a merge type","No merge type",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     rasterUtil.mergeType mType = (rasterUtil.mergeType)Enum.Parse(typeof(rasterUtil.mergeType),mtypStr);
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Merging Rasters. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     try
     {
         outraster = rsUtil.createRaster(rsUtil.calcMosaicFunction(rsArr,mType));//rsUtil.mergeRasterFunction(rsArr, mType, rstNm);//
         if (mp != null&&addToMap)
         {
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             rstLyr.CreateFromRaster(outraster);
             rstLyr.Visible = false;
             rstLyr.Name = rstNm;
             mp.AddLayer((ILayer)rstLyr);
         }
         outrastername = rstNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Mosaic Raster" + t);
         rp.enableClose();
         this.Close();
     }
 }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbRaster.Text;
            string inFocalStat = cmbFocalStat.Text;
            string outNmRst = txtOutName.Text;
            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Rasterr","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (inFocalStat == "" || inFocalStat == null)
            {
                MessageBox.Show("You must specify an Focal Statistic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            HashSet<string> offsets = new HashSet<string>();
            for (int i = 0; i < dgvAzDs.RowCount; i++)
            {
                string az = dgvAzDs[0, i].Value.ToString();
                string ds = dgvAzDs[1, i].Value.ToString();
                offsets.Add(az + ";" + ds);

            }
            if (offsets.Count < 1)
            {
                MessageBox.Show("Nothing specified for offset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRaster rs1 = rstDic[inRst1Nm];
            IRaster outRs = null;
            rasterUtil.focalType fcType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), inFocalStat);
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                outRs = rsUtil.createRaster(rsUtil.calcFocalSampleFunction(rs1, offsets, fcType));
                outraster = outRs;
                outrastername = outNmRst;
                if (mp != null && addToMap)
                {
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name = OutRasterName;
                    rsLyr.Visible = false;
                    mp.AddLayer(rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Focal Sample Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #53
0
        private void btnClip_Click(object sender, EventArgs e)
        {
            string rstNm  = cmbInRaster1.Text;
            string outNm  = txtOutName.Text;
            string visStr = cmbVis.Text;
            string irStr  = cmbIr.Text;

            if (visStr == "" || visStr == null || rstNm == "" || rstNm == null || irStr == "" || irStr == null)
            {
                MessageBox.Show("You must have a raster layer selected and a valid visual and ir band index value", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNm == "" || outNm == null)
            {
                MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            int visVl = System.Convert.ToInt32(visStr) - 1;
            int irVl  = System.Convert.ToInt32(irStr) - 1;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Making Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                IRaster rst = rstDic[rstNm];
                outraster = rsUtil.returnRaster(rsUtil.calcNDVIFunction(rst, visVl, irVl));
                if (mp != null && addToMap)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromRaster(outraster);
                    rstLyr.Name    = outNm;
                    rstLyr.Visible = false;
                    mp.AddLayer(rstLyr);
                }
                outrastername     = outNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Making Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnExplode_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string linkFld = cmbLinkedFld.Text;
            if (smpFtrNm == null || smpFtrNm == ""||linkFld==null||linkFld=="" )
            {
                MessageBox.Show("sample location not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Dictionary<double, double> azDsDic = new Dictionary<double, double>();
            for (int i = 0; i < dgvAzDs.RowCount; i++)
            {
                double az = System.Convert.ToDouble(dgvAzDs[0, i].Value);
                double ds = System.Convert.ToDouble(dgvAzDs[1, i].Value);
                if (!azDsDic.ContainsKey(az))
                {
                    azDsDic.Add(az, ds);
                }
            }
            if (azDsDic.Count < 1)
            {
                MessageBox.Show("Nothing specified for offset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Exploding Samples");
            rp.addMessage("This may take a while...");
            rp.stepPGBar(20);
            rp.Show();
            rp.Refresh();
            DateTime dt1 = DateTime.Now;
            try
            {
                IFeatureClass ftrCls = ftrDic[smpFtrNm];
                string outNm = smpFtrNm + "_explode";
                IFeatureClass outFtr = geoUtil.explodePoints(ftrDic[smpFtrNm],linkFld,azDsDic,outNm);
                IDataset dSet = (IDataset)outFtr;
                string outPath = dSet.Workspace.PathName + "\\" + outNm;
                rp.addMessage("New exploded feature class is stored at the following location:\n\t" + outPath);
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt1);
                string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                if (MessageBox.Show("Do you want to add layer to map?", "Add Layer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    IFeatureLayer ftrLyr = new FeatureLayerClass();
                    ftrLyr.FeatureClass = outFtr;
                    ftrLyr.Name = outNm;
                    mp.AddLayer((ILayer)ftrLyr);
                }

            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.stepPGBar(100);
                rp.enableClose();
                this.Close();
            }
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string mapFld = cmbMap.Text;

            double alpha = System.Convert.ToDouble(nudAlpha.Value);
            double prop = System.Convert.ToDouble(nudProp.Value);
            string outModelPath = txtOutputPath.Text;
            if (outModelPath == null || outModelPath == "")
            {
                MessageBox.Show("You must select an output model or specify a numeric integer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (smpFtrNm == null || smpFtrNm == "")
            {
                MessageBox.Show("You must select a feature Class or Table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Visible = false;
            this.Refresh();
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Selecting samples this may take a while...");
            rp.stepPGBar(10);
            rp.Show();
            rp.Refresh();
            ITable ftrCls = ftrDic[smpFtrNm];
            DateTime dt1 = DateTime.Now;
            try
            {
                featureUtil ftrUtil = new featureUtil();
                int ns;
                if(Int32.TryParse(outModelPath,out ns))
                {
                    //MessageBox.Show(ns.ToString());
                    if (mapFld == null || mapFld == "" || ftrCls.FindField(mapFld) == -1)
                    {
                        ftrUtil.selectRandomFeaturesToSample(ftrCls, ns);
                    }
                    else
                    {
                        ftrUtil.selectEqualFeaturesToSample(ftrCls, mapFld, ns, chbEqual.Checked);
                    }
                }
                else
                {
                    esriUtil.Statistics.dataPrepBase.modelTypes mType = esriUtil.Statistics.ModelHelper.getModelType(outModelPath);
                    if (mapFld == null || mapFld == "")
                    {
                        if (mType == Statistics.dataPrepBase.modelTypes.Accuracy || mType == Statistics.dataPrepBase.modelTypes.Cluster)
                        {
                            MessageBox.Show("You must select a map field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    switch (mType)
                    {
                        case esriUtil.Statistics.dataPrepBase.modelTypes.Accuracy:
                            ftrUtil.selectAccuracyFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha,chbEqual.Checked);
                            break;
                        case esriUtil.Statistics.dataPrepBase.modelTypes.Cluster:
                            ftrUtil.selectClusterFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha,chbEqual.Checked);
                            break;
                        case Statistics.dataPrepBase.modelTypes.KS:
                            rp.Visible = false;
                            ITable sts = null;
                            if (MessageBox.Show("Do you want to supplement samples if needed?", "Supplement samples", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                            {
                                sts = getTableFromUser();
                            }
                            rp.Visible = true;
                            ftrUtil.selectKSFeaturesToSample(ftrCls,sts, outModelPath, mapFld);
                            break;
                        case esriUtil.Statistics.dataPrepBase.modelTypes.CovCorr:
                            ftrUtil.selectCovCorrFeaturesToSample(ftrCls, outModelPath, prop, alpha);
                            break;
                        case esriUtil.Statistics.dataPrepBase.modelTypes.StrataCovCorr:
                            ftrUtil.selectClusterFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha, chbEqual.Checked);
                            break;
                        case esriUtil.Statistics.dataPrepBase.modelTypes.PCA:
                            ftrUtil.selectPcaFeaturesToSample(ftrCls, outModelPath, prop, alpha);
                            break;
                        case esriUtil.Statistics.dataPrepBase.modelTypes.LinearRegression:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.MvlRegression:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.LogisticRegression:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.PLR:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.RandomForest:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.SoftMax:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.Cart:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.L3:
                        case esriUtil.Statistics.dataPrepBase.modelTypes.TTEST:
                        default:
                            rp.addMessage("Sample selection for this model type is not currently supported!");
                            break;
                    }
                }

            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt1);
                int hr = ts.Hours;
                int min = ts.Minutes;
                int sec = ts.Seconds;
                rp.stepPGBar(100);
                rp.addMessage("Finished selecting samples in " + hr.ToString() + " hours " + min.ToString() + " minutes " + sec.ToString() + " seconds");
                rp.enableClose();
                this.Close();
            }
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string strataStr = cmbStrata.Text;
            string plotsStr = cmbPlots.Text;
            string standsStr = cmbStands.Text;
            if (strataStr == null || strataStr == "")
            {
                MessageBox.Show("You must specify a Stratification layer", "No Zone", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (plotsStr == null || plotsStr == "")
            {
                MessageBox.Show("You must specify a plots layer", "No Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (lsbFields.Items.Count < 1 )
            {
                MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List<IField> fldLst = new List<IField>();
            IFeatureClass pltFtrCls = ftrDic[plotsStr];
            for (int i = 0; i < lsbFields.Items.Count; i++)
            {
                IField fld  = pltFtrCls.Fields.get_Field(pltFtrCls.FindField(lsbFields.Items[i].ToString()));
                fldLst.Add(fld);
            }
            this.Visible = false;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;
            rp.addMessage("Summarizing plots. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            //Statistics.ModelHelper.runProgressBar("Summarizing");
            try
            {
                IFeatureClass standFtrCls = null;
                if(ftrDic.ContainsKey(standsStr))
                {
                    standFtrCls = ftrDic[standsStr];
                }
                if (rstDic.ContainsKey(strataStr))
                {
                    rp.addMessage("Summarizing FIA plots using raster...");
                    IRaster strataRs = rstDic[strataStr];
                    IFunctionRasterDataset stratafDset = rsUtil.createIdentityRaster(strataRs);
                    //outTbl = rsUtil.zonalStats(zRs, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                    fiaIntegration.summarizeBiomassPolygon(pltFtrCls, fldLst.ToArray(), stratafDset, standFtrCls, geoUtil, rsUtil);
                }
                else
                {
                    rp.addMessage("Summarizing FIA plots using polygon");
                    rp.Refresh();
                    IFeatureClass strataFtr = ftrDic[strataStr];
                    //outTbl = rsUtil.zonalStats(zFtr, zFld, vRs, oTbl, rsLst.ToArray(), rp, chbClassCounts.Checked);
                    fiaIntegration.summarizeBiomassPolygon(pltFtrCls, fldLst.ToArray(),strataFtr, standFtrCls, geoUtil);
                }
                if (mp != null && addToMap)
                {

                    rp.Refresh();

                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                Statistics.ModelHelper.closeProgressBar();
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2.Subtract(dt);
                string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished summarizing" + t);
                rp.enableClose();
                this.Close();
            }
        }
 private void btnClip_Click(object sender, EventArgs e)
 {
     string rstNm = cmbInRaster1.Text;
     string outNm = txtOutName.Text;
     string pixelNm = cmbPixel.Text;
     if (pixelNm == "" || pixelNm == null || rstNm == "" || rstNm == null)
     {
         MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if(outNm==""||outNm==null)
     {
         MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Transforming Raster. This may take a while...");
     rp.stepPGBar(10);
     rp.TopMost = true;
     rp.Show();
     try
     {
         IRaster rst = rstDic[rstNm];
         rasterUtil.transType pType = (rasterUtil.transType)Enum.Parse(typeof(rasterUtil.transType),pixelNm);
         outraster = rsUtil.returnRaster(rsUtil.calcMathRasterFunction(rst,pType));
         if (mp != null&&addToMap)
         {
             rp.addMessage("Calculating Statistics...");
             rp.Show();
             rp.Refresh();
             IRasterLayer rstLyr = new RasterLayerClass();
             //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
             rstLyr.CreateFromRaster(outraster);
             rstLyr.Name = outNm;
             rstLyr.Visible = false;
             mp.AddLayer(rstLyr);
         }
         outrastername = outNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Transforming Raster" + t);
         rp.enableClose();
         this.Close();
     }
 }
コード例 #58
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string smpFtrNm = cmbSampleFeatureClass.Text;
            string mapFld   = cmbMap.Text;

            double alpha        = System.Convert.ToDouble(nudAlpha.Value);
            double prop         = System.Convert.ToDouble(nudProp.Value);
            string outModelPath = txtOutputPath.Text;

            if (outModelPath == null || outModelPath == "")
            {
                MessageBox.Show("You must select an output model or specify a numeric integer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (smpFtrNm == null || smpFtrNm == "")
            {
                MessageBox.Show("You must select a feature Class or Table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            this.Visible = false;
            this.Refresh();
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Selecting samples this may take a while...");
            rp.stepPGBar(10);
            rp.Show();
            rp.Refresh();
            ITable   ftrCls = ftrDic[smpFtrNm];
            DateTime dt1    = DateTime.Now;

            try
            {
                featureUtil ftrUtil = new featureUtil();
                int         ns;
                if (Int32.TryParse(outModelPath, out ns))
                {
                    //MessageBox.Show(ns.ToString());
                    if (mapFld == null || mapFld == "" || ftrCls.FindField(mapFld) == -1)
                    {
                        ftrUtil.selectRandomFeaturesToSample(ftrCls, ns);
                    }
                    else
                    {
                        ftrUtil.selectEqualFeaturesToSample(ftrCls, mapFld, ns, chbEqual.Checked);
                    }
                }
                else
                {
                    esriUtil.Statistics.dataPrepBase.modelTypes mType = esriUtil.Statistics.ModelHelper.getModelType(outModelPath);
                    if (mapFld == null || mapFld == "")
                    {
                        if (mType == Statistics.dataPrepBase.modelTypes.Accuracy || mType == Statistics.dataPrepBase.modelTypes.Cluster)
                        {
                            MessageBox.Show("You must select a map field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    switch (mType)
                    {
                    case esriUtil.Statistics.dataPrepBase.modelTypes.Accuracy:
                        ftrUtil.selectAccuracyFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha, chbEqual.Checked);
                        break;

                    case esriUtil.Statistics.dataPrepBase.modelTypes.Cluster:
                        ftrUtil.selectClusterFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha, chbEqual.Checked);
                        break;

                    case Statistics.dataPrepBase.modelTypes.KS:
                        rp.Visible = false;
                        ITable sts = null;
                        if (MessageBox.Show("Do you want to supplement samples if needed?", "Supplement samples", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            sts = getTableFromUser();
                        }
                        rp.Visible = true;
                        ftrUtil.selectKSFeaturesToSample(ftrCls, sts, outModelPath, mapFld);
                        break;

                    case esriUtil.Statistics.dataPrepBase.modelTypes.CovCorr:
                        ftrUtil.selectCovCorrFeaturesToSample(ftrCls, outModelPath, prop, alpha);
                        break;

                    case esriUtil.Statistics.dataPrepBase.modelTypes.StrataCovCorr:
                        ftrUtil.selectClusterFeaturesToSample(ftrCls, outModelPath, mapFld, prop, alpha, chbEqual.Checked);
                        break;

                    case esriUtil.Statistics.dataPrepBase.modelTypes.PCA:
                        ftrUtil.selectPcaFeaturesToSample(ftrCls, outModelPath, prop, alpha);
                        break;

                    case esriUtil.Statistics.dataPrepBase.modelTypes.LinearRegression:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.MvlRegression:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.LogisticRegression:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.PLR:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.RandomForest:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.SoftMax:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.Cart:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.L3:
                    case esriUtil.Statistics.dataPrepBase.modelTypes.TTEST:
                    default:
                        rp.addMessage("Sample selection for this model type is not currently supported!");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt1);
                int      hr  = ts.Hours;
                int      min = ts.Minutes;
                int      sec = ts.Seconds;
                rp.stepPGBar(100);
                rp.addMessage("Finished selecting samples in " + hr.ToString() + " hours " + min.ToString() + " minutes " + sec.ToString() + " seconds");
                rp.enableClose();
                this.Close();
            }
        }
コード例 #59
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm = cmbInRaster1.Text;
            string inRst2Nm = cmbInRaster2.Text;
            string inRst3Nm = cmbInRaster3.Text;
            string outNmRst = txtOutName.Text;

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inRst2Nm == "" || inRst2Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inRst3Nm == "" || inRst3Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 3 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            object rs1, rs2, rs3;

            if (rstDic.ContainsKey(inRst1Nm))
            {
                rs1 = rstDic[inRst1Nm];
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 1", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (rstDic.ContainsKey(inRst2Nm))
            {
                rs2 = rstDic[inRst2Nm];
            }
            else if (rsUtil.isNumeric(inRst2Nm))
            {
                rs2 = inRst2Nm;
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 2 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (rstDic.ContainsKey(inRst3Nm))
            {
                rs3 = rstDic[inRst3Nm];
            }
            else if (rsUtil.isNumeric(inRst3Nm))
            {
                rs3 = inRst3Nm;
            }
            else
            {
                MessageBox.Show("You must specify an input raster for In Raster 3 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                outraster     = rsUtil.createRaster(rsUtil.conditionalRasterFunction(rs1, rs2, rs3));
                outrastername = outNmRst;
                if (mp != null && aM)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    //rsUtil.calcStatsAndHist(outraster);
                    IRasterLayer rsLyr = new RasterLayerClass();
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = outrastername;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Conditional Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }
コード例 #60
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string demStr = cmbDem.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(demStr))
            {
                MessageBox.Show("Dem must be specified before executing");
                return;
            }
            string unitsStr = cmbUnits.Text;

            if (unitsStr == "")
            {
                MessageBox.Show("Speed Units must be specified before executing");
                return;
            }
            string roadsStr = cmbRoad.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(roadsStr) && !frmHlp.FeatureDictionary.ContainsKey(roadsStr))
            {
                MessageBox.Show("Roads Layer or Accumulation Raster must be specified before executing");
                return;
            }
            string facilityStr = cmbFacility.Text;
            string speedFldStr = cmbSpeed.Text;

            if (chbHours.Checked)
            {
                if (!frmHlp.FeatureDictionary.ContainsKey(facilityStr))
                {
                    MessageBox.Show("Facility Layer must be specified before executing");
                    return;
                }

                if (speedFldStr == "")
                {
                    MessageBox.Show("Speed Fld must be specified before executing");
                    return;
                }
            }
            string onRateStr = cmbOnRate.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(onRateStr) && !rsUtil.isNumeric(onRateStr))
            {
                MessageBox.Show("On Road Machine Rate must be specified before executing");
                return;
            }
            float  onPay       = System.Convert.ToSingle(nudOnPayload.Value);
            string offSpeedStr = cmbOffRoadSpeed.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(offSpeedStr) && !rsUtil.isNumeric(offSpeedStr))
            {
                MessageBox.Show("Off Road Speed or Off Road hours Raster must be specified before executing");
                return;
            }
            string offRateStr = cmbOffRate.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(offRateStr) && !rsUtil.isNumeric(offRateStr))
            {
                MessageBox.Show("Off Road Machine Rate must be specified before executing");
                return;
            }
            string offBarriersStr = cmbBarrier.Text;
            float  offPay         = System.Convert.ToSingle(nudOffPayload.Value);
            string opsStr         = cmbOps.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(opsStr) && !rsUtil.isNumeric(opsStr))
            {
                MessageBox.Show("Operation Rate must be specified before executing");
                return;
            }
            string otherStr = cmbOther.Text;

            if (!frmHlp.FunctionRasterDictionary.ContainsKey(otherStr) && !rsUtil.isNumeric(otherStr))
            {
                MessageBox.Show("Other rate must be specified before executing");
                return;
            }
            string     wksStr = txtOutWks.Text;
            IWorkspace wks    = geoUtil.OpenWorkSpace(wksStr);

            if (wks == null)
            {
                MessageBox.Show("A valid file geodatabase must be specified before executing");
                return;
            }
            RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog();
            rp.addMessage("Calculating delivered cost surface...\nThis may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            DateTime dt = DateTime.Now;

            this.Visible = false;
            try
            {
                IFunctionRasterDataset  Dem   = frmHlp.FunctionRasterDictionary[demStr];
                TransRouting.SpeedUnits units = (TransRouting.SpeedUnits)Enum.Parse(typeof(TransRouting.SpeedUnits), unitsStr);
                TransRouting            tr    = new TransRouting(wks, Dem, units);
                if (rsUtil.isNumeric(onRateStr))
                {
                    tr.OnRoadMachineRate = System.Convert.ToSingle(onRateStr);
                }
                else
                {
                    tr.OnRoadMachineRateRaster = frmHlp.FunctionRasterDictionary[onRateStr];
                }
                tr.OnRoadPayLoad = onPay;
                if (rsUtil.isNumeric(offRateStr))
                {
                    tr.OffRoadMachineRate = System.Convert.ToSingle(offRateStr);
                }
                else
                {
                    tr.OffRoadMachineRateRaster = frmHlp.FunctionRasterDictionary[offRateStr];
                }
                tr.OffRoadPayLoad = offPay;
                if (rsUtil.isNumeric(opsStr))
                {
                    tr.OperationsCost = System.Convert.ToSingle(opsStr);
                }
                else
                {
                    tr.OperationsCostRaster = frmHlp.FunctionRasterDictionary[opsStr];
                }
                if (rsUtil.isNumeric(otherStr))
                {
                    tr.OtherCost = System.Convert.ToSingle(otherStr);
                }
                else
                {
                    tr.OtherCostRaster = frmHlp.FunctionRasterDictionary[otherStr];
                }
                if (chbHours.Checked)
                {
                    if (frmHlp.FeatureDictionary.ContainsKey(roadsStr))
                    {
                        tr.RoadFeatureClass = frmHlp.FeatureDictionary[roadsStr];
                    }
                    else
                    {
                        tr.RoadRaster = frmHlp.FunctionRasterDictionary[roadsStr];
                    }
                    tr.FacilityFeatureClass = frmHlp.FeatureDictionary[facilityStr];
                    tr.RoadsSpeedField      = speedFldStr;
                    if (rsUtil.isNumeric(offSpeedStr))
                    {
                        tr.OffRoadSpeed = System.Convert.ToSingle(offSpeedStr);
                    }
                    else
                    {
                        tr.OffRoadSpeedRaster = frmHlp.FunctionRasterDictionary[offSpeedStr];
                    }
                    if (frmHlp.FeatureDictionary.ContainsKey(offBarriersStr))
                    {
                        tr.BarriersFeatureClass = frmHlp.FeatureDictionary[offBarriersStr];
                    }
                    else if (frmHlp.FunctionRasterDictionary.ContainsKey(offBarriersStr))
                    {
                        tr.BarrierRaster = frmHlp.FunctionRasterDictionary[offBarriersStr];
                    }
                }
                else
                {
                    tr.FunctionAccumulatedPathAllocation   = frmHlp.FunctionRasterDictionary[roadsStr];
                    tr.FunctionAccumulatedFromPathDistance = frmHlp.FunctionRasterDictionary[offSpeedStr];
                }
                IFunctionRasterDataset DollarsPerTon = tr.OutDollarsTonsRaster;
                //IFunctionRasterDataset outraster = rsUtil.createRaster(DollarsPerTon);
                if (frmHlp.TheMap != null)
                {
                    rp.addMessage("Calculating Statistics...");
                    rp.Refresh();
                    IRasterLayer rstLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset);
                    rstLyr.CreateFromDataset((IRasterDataset)DollarsPerTon);
                    rstLyr.Name    = "DollarsPerTon";
                    rstLyr.Visible = false;
                    frmHlp.TheMap.AddLayer(rstLyr);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished creating delivered cost surfaces" + t);
                rp.enableClose();
                this.Close();
            }
        }