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(); } }
private void btnExecute_Click(object sender, EventArgs e) { string ftrPath = cmbFtrCls.Text; string imgPath = txtImgWks.Text; string outPath = txtOutWks.Text; if (ftrPath == "" || ftrPath == null) { MessageBox.Show("Missing Feature Class"); return; } if (imgPath == "" || imgPath == null) { MessageBox.Show("Missing image directory\\workspace"); return; } if (outPath == "" || outPath == null) { MessageBox.Show("Missing output workspace"); return; } RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false); this.Visible = false; rd.addMessage("Making Tiles. This may take a while...."); rd.stepPGBar(10); rd.TopMost = true; DateTime dt = DateTime.Now; rd.Show(); try { IFeatureClass ftrCls = ftrDic[ftrPath]; IWorkspace imgWks = geoUtil.OpenRasterWorkspace(imgPath); IWorkspace outWks = geoUtil.OpenWorkSpace(outPath); IFunctionRasterDataset[] outDset = ftrUtil.tiledMosaics(ftrCls, imgWks, outWks); for (int i = 0; i < outDset.Length; i++) { IRasterLayer lyr = new RasterLayerClass(); lyr.Name = "Tile_" + (i + 1).ToString(); lyr.CreateFromDataset((IRasterDataset)outDset[i]); frmHlp.TheMap.AddLayer(lyr); } } catch (Exception ex) { rd.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 ."; rd.stepPGBar(100); rd.addMessage("Finished Making Tiles" + t); rd.enableClose(); this.Close(); rd.stepPGBar(100); } }
private void btnExecute_Click(object sender, EventArgs e) { string lasDirPath = txtLasDir.Text; string outDirPath = txtOutDir.Text; int cellSize = System.Convert.ToInt32(nudCellSize.Value); double cutHeight = 0; string dtmDirPath = txtDTM.Text; bool dtmExists = true; if (lasDirPath == "" || lasDirPath == null) { System.Windows.Forms.MessageBox.Show("No las directory specified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (outDirPath == "" || outDirPath == null) { System.Windows.Forms.MessageBox.Show("No output directory specified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dtmDirPath == "" || dtmDirPath == null) { dtmExists = false; } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Running Fusion's Grid Metrics. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { if (dtmExists) { fsInt.RunGridMetrics(lasDirPath, outDirPath, cellSize, cutHeight, dtmDirPath, System.Convert.ToDouble(nudCuttOffBelow.Value), System.Convert.ToDouble(nudCuttOffAbove.Value)); } else { fsInt.RunGridMetrics(lasDirPath, outDirPath, cellSize, cutHeight); } 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 metrics in" + t); rp.enableClose(); this.Close(); } }
private void btnRun_Click(object sender, EventArgs e) { string inp = txtInDir.Text; string outfl = txtOutDir.Text; string polyPath = cmbROI.Text; string extStr = cmbExt.Text; if (inp == null || inp == "") { MessageBox.Show("No Image Directory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (outfl == null || outfl == "") { MessageBox.Show("No Output CSV file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (polyPath == null || polyPath == "") { MessageBox.Show("No ROI Selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (extStr == null || extStr == "") { MessageBox.Show("No image extension selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ext = (photoAnalysis.extensionType)Enum.Parse(typeof(photoAnalysis.extensionType), extStr); IFeatureClass ftrCls = frmHelper.FeatureDictionary[polyPath]; IDataset dSet = (IDataset)ftrCls; string fPath = dSet.Workspace.PathName + "\\" + dSet.BrowseName; this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rdp = new RunningProcess.frmRunningProcessDialog(false); rdp.addMessage("Running photo analysis..."); rdp.TopMost = true; rdp.Show(); DateTime dt1 = DateTime.Now; try { photoAnalysis photoA = new photoAnalysis(inDirPath[0], fPath, outCsvPath, ext); photoA.runAnalysis(); } catch (Exception exc) { rdp.addMessage(exc.ToString()); } finally { DateTime dt2 = DateTime.Now; TimeSpan ts = dt2.Subtract(dt1); rdp.addMessage("Finished photo analysis in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds"); rdp.stepPGBar(100); rdp.enableClose(); 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 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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
private void btnExecute_Click(object sender, EventArgs e) { string MetricsDirPath = txtMetricsDir.Text; string outDirPath = txtOutDir.Text; if (MetricsDirPath == "" || MetricsDirPath == null) { System.Windows.Forms.MessageBox.Show("No metrics directory specified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (outDirPath == "" || outDirPath == null) { System.Windows.Forms.MessageBox.Show("No output directory specified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lstMetrics.Items.Count < 1) { MessageBox.Show("No Metrics selected to convert to raster", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string[] metrics = lstMetrics.Items.Cast <string>().ToArray(); this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Converting Grid Metrics to Raster. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { fsInt.ConvertGridMetricsToRaster(MetricsDirPath, outDirPath, metrics); 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 in" + 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 btnExecute_Click(object sender, EventArgs e) { string inftrStr = cmbInFtrCls.Text; int splits = System.Convert.ToInt32(nudSplits.Value); string outFtrStr = txtOutFtrCls.Text; if (inftrStr == "" || inftrStr == null) { MessageBox.Show("Missing input Feature Class"); return; } if (outFtrStr == "" || outFtrStr == null) { MessageBox.Show("Missing output Feature Class path"); return; } RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false); this.Visible = false; rd.addMessage("Splitting Feature Class. This may take a while...."); rd.stepPGBar(10); rd.TopMost = true; DateTime dt = DateTime.Now; rd.Show(); try { IFeatureClass ftrCls = frmHlp.FeatureDictionary[inftrStr]; IFeatureClass outFtrCls = ftrUtil.splitPolyFeatures(ftrCls, splits, outFtrStr); IFeatureLayer lyr = new FeatureLayerClass(); lyr.FeatureClass = outFtrCls; lyr.Name = ((IDataset)outFtrCls).Name; frmHlp.TheMap.AddLayer(lyr); } catch (Exception ex) { rd.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 ."; rd.stepPGBar(100); rd.addMessage("Finished splitting" + t); rd.enableClose(); this.Close(); rd.stepPGBar(100); } }
private void btnExecute_Click(object sender, EventArgs e) { string svrStr = cmbService.Text; string lyrStr = cmbLayer.Text; string outPath = txtOutFtrCls.Text; bool clip = chbDisplayExtent.Checked; if (mpSvr == null) { MessageBox.Show("No Map server selected"); return; } if (!mpLayerDic.ContainsKey(lyrStr)) { MessageBox.Show("No Layer selected"); } RunningProcess.frmRunningProcessDialog rd = new RunningProcess.frmRunningProcessDialog(false); this.Visible = false; rd.addMessage("Downloading data. This may take a while...."); rd.stepPGBar(10); rd.TopMost = true; DateTime dt = DateTime.Now; rd.Show(); try { IFeatureClass ftrCls = mapserviceutility.createFeatureClassFromMapService(outPath, mpSvr, mpName, mpLayerDic[lyrStr]); IFeatureLayer lyr = new FeatureLayerClass(); lyr.FeatureClass = ftrCls; lyr.Name = ((IDataset)ftrCls).Name; frmHlp.TheMap.AddLayer(lyr); } catch (Exception ex) { rd.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 ."; rd.stepPGBar(100); rd.addMessage("Finished splitting" + t); rd.enableClose(); this.Close(); rd.stepPGBar(100); } }
private void removelocks() { IFunctionRasterDataset[] rsArr = { rsfine10, rsfine50, rst1Fine10, rst1Fine50, rshsf10, rshsf50 }; foreach (IFunctionRasterDataset rs in rsArr) { IDataset dSet = (IDataset)rs; try { rsUtil.removeLock(dSet); } catch { rpForm.addMessage("Could not remove lock on " + dSet.BrowseName); } } }
private void btnViewOrder_Click(object sender, EventArgs e) { if (!System.IO.File.Exists(plrR.SasOutputFile)) { MessageBox.Show("You must first select a sample location that has been used to create a PLR model before you can use this button!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } esriUtil.Forms.RunningProcess.frmRunningProcessDialog frmD = new RunningProcess.frmRunningProcessDialog(false); frmD.stepPGBar(100); frmD.addMessage("Modeling parameters are as follows:"); frmD.addMessage(String.Join("\n", plrR.OutParameters.ToArray())); frmD.addMessage("Raster layers (ignoring intercept) must be specified in the same order!"); frmD.Show(); frmD.TopLevel = true; frmD.enableClose(); }
private void btnVariables_Click(object sender, EventArgs e) { string mPath = txtOutputPath.Text; Statistics.ModelHelper mh = new Statistics.ModelHelper(mPath); mh.openModelReport(mPath, 0.05, false); Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); rp.stepPGBar(100); rp.Text = "Model Variables"; rp.enableClose(); rp.addMessage("Independent variable names:"); foreach (string s in mh.IndependentVariables) { rp.addMessage(s); } rp.Show(); }
private void btnExecute_Click(object sender, EventArgs e) { string lasDir = txtLasDir.Text; string gLasDir = txtOutDir.Text; int cellSize = System.Convert.ToInt32(nudCellSize.Value); if (!System.IO.Directory.Exists(lasDir)) { MessageBox.Show("Could not find the LAS directory!", "Error", MessageBoxButtons.OK); return; } if (!System.IO.Directory.Exists(gLasDir)) { MessageBox.Show("Could not find the Ground LAS directory!", "Error", MessageBoxButtons.OK); return; } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Running ground Filter. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { fsInt.RunGroundFilter(lasDir, gLasDir, cellSize); 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 filtered las files in" + 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(); } }
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 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 txtDir = txtLasDir.Text; if (!System.IO.Directory.Exists(txtDir)) { MessageBox.Show("Directory does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Cleaning files and directories. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { rp.addMessage("Directory is now located at:\n\t " + fsInt.checkAndRenameAllFiles(txtDir, ".las")); 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 cleaning files and directory in" + 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 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) { 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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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) { 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 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 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 btnViewOrder_Click(object sender, EventArgs e) { if (!System.IO.File.Exists(plrR.SasOutputFile)) { MessageBox.Show("You must first select a sample location that has been used to create a PLR model before you can use this button!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } esriUtil.Forms.RunningProcess.frmRunningProcessDialog frmD = new RunningProcess.frmRunningProcessDialog(false); frmD.stepPGBar(100); frmD.addMessage("Modeling parameters are as follows:"); frmD.addMessage(String.Join("\n",plrR.OutParameters.ToArray())); frmD.addMessage("Raster layers (ignoring intercept) must be specified in the same order!"); frmD.Show(); frmD.TopLevel = true; frmD.enableClose(); }
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(); } }
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 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 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(); } }
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 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(); } }
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 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(); } }
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 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 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 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 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(); } }
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(); } }
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 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(); } }
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 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(); } }
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(); } }
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 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(); } }
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(); } }