示例#1
0
 public void segmentLandFireData()
 {
     try
     {
         int cnt = 0;
         foreach (IRaster rs in new IRaster[] { vegRs, htRs, covRs, demRs })
         {
             if (rs == null)
             {
                 Console.WriteLine("Null Raster found at iteration " + cnt.ToString());
                 cnt++;
                 return;
             }
         }
         IRaster rs1 = vegRs;
         IRaster rs2 = rescaleHt();
         IRaster rs3 = rescaleCov();
         IRaster rs4 = calcTopo();
         IRaster rs5 = rsUtil.returnRaster(rsUtil.compositeBandFunction(new IRaster[] { rs1, rs2, rs3, rs4 }));
         IRaster sMd = rsUtil.createRaster(rsUtil.localStatisticsfunction(rs5, rasterUtil.localType.SUM));
         modelrs = rsUtil.returnRaster(rsUtil.saveRasterToDataset(rsUtil.returnRaster(sMd, rstPixelType.PT_LONG), "lfSeg", landfireworkspace));
         //Console.WriteLine("Finished Segementing Raster");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
示例#2
0
        public void btnExecute_Click(object sender, EventArgs e)
        {
            string tblNm = txtOutNm.Text;

            if (tblNm == null || tblNm == "")
            {
                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 Raster Attribute Table. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                string                 outDbStr = geoUtil.getDatabasePath(tblNm);
                string                 outName  = System.IO.Path.GetFileNameWithoutExtension(tblNm);
                IWorkspace             wks      = geoUtil.OpenWorkSpace(outDbStr);
                IFunctionRasterDataset fDset    = rsUtil.compositeBandFunction(rsBc);
                outtbl            = rsUtil.calcCombinRasterFunctionTable(fDset, wks, outName);
                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 attribute table");
                rp.enableClose();
                this.Close();
            }
        }
示例#3
0
        private IFunctionRasterDataset transform()
        {
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < coef.Length; i++)
            {
                double[] c                 = coef[i];
                double   intercept         = c[0];
                double   slope             = c[1];
                IFunctionRasterDataset tRs = rsUtil.getBand(transformRaster, i);
                IFunctionRasterDataset pRs = rsUtil.calcArithmaticFunction(tRs, slope, esriRasterArithmeticOperation.esriRasterMultiply);
                IFunctionRasterDataset fRs = rsUtil.calcArithmaticFunction(pRs, intercept, esriRasterArithmeticOperation.esriRasterPlus);
                IFunctionRasterDataset bRs = rsUtil.convertToDifFormatFunction(fRs, rsType);
                rsBc.AppendBand(((IRasterBandCollection)bRs).Item(0));
            }
            OutRaster = rsUtil.compositeBandFunction(rsBc);
            return(OutRaster);
        }
示例#4
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();
            }
        }
示例#5
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();
            }
        }
示例#6
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();
            }
        }