private void PerformDoD(Epoch DoDEpoch, ThresholdProps tProps) { DEMSurvey NewDEM = DoDEpoch.NewDEM; DEMSurvey OldDEM = DoDEpoch.OldDEM; string aoiName = AOIMask is Project.Masks.AOIMask ? AOIMask.Name : string.Empty; string dodName = frmDoDProperties.GetUniqueAnalysisName(NewDEM.Name, OldDEM.Name, tProps.ThresholdString, aoiName); System.IO.DirectoryInfo dFolder = ProjectManager.Project.GetDoDFolder(); ChangeDetectionEngineBase cdEngine = null; switch (tProps.Method) { case ThresholdProps.ThresholdMethods.MinLoD: cdEngine = new ChangeDetectionEngineMinLoD(NewDEM, OldDEM, AOIMask, tProps.Threshold, true); break; case ThresholdProps.ThresholdMethods.Propagated: cdEngine = new ChangeDetectionEnginePropProb(NewDEM, OldDEM, DoDEpoch.NewDEMErrorSurface, DoDEpoch.OldDEMErrorSurface, AOIMask, true); break; case ThresholdProps.ThresholdMethods.Probabilistic: cdEngine = new ChangeDetectionEngineProbabilistic(NewDEM, OldDEM, AOIMask, DoDEpoch.NewDEMErrorSurface, DoDEpoch.OldDEMErrorSurface, tProps.Threshold, tProps.SpatialCoherenceProps, true); break; } DoDBase dod = cdEngine.Calculate(dodName, dFolder, true, ProjectManager.Project.Units); ProjectManager.Project.DoDs.Add(dod); }
private void PerformDoD(BatchProps props) { string aoiName = props.AOIMask is Project.Masks.AOIMask ? props.AOIMask.Name : string.Empty; string dodName = frmDoDProperties.GetUniqueAnalysisName(props.NewSurface.Name, props.OldSurface.Name, props.ThresholdProps.ThresholdString, aoiName); System.IO.DirectoryInfo dFolder = ProjectManager.Project.GetDoDFolder(); ChangeDetectionEngineBase cdEngine = null; switch (props.ThresholdProps.Method) { case ThresholdProps.ThresholdMethods.MinLoD: cdEngine = new ChangeDetectionEngineMinLoD(props.NewSurface, props.OldSurface, props.AOIMask, props.ThresholdProps.Threshold, true); break; case ThresholdProps.ThresholdMethods.Propagated: cdEngine = new ChangeDetectionEnginePropProb(props.NewSurface, props.OldSurface, props.NewError, props.OldError, props.AOIMask, true); break; case ThresholdProps.ThresholdMethods.Probabilistic: cdEngine = new ChangeDetectionEngineProbabilistic(props.NewSurface, props.OldSurface, props.AOIMask, props.NewError, props.OldError, props.ThresholdProps.Threshold, props.ThresholdProps.SpatialCoherenceProps, true); break; } DoDBase dod = cdEngine.Calculate(dodName, dFolder, true, ProjectManager.Project.Units); ProjectManager.Project.DoDs.Add(dod); }
public void Initialize(DoDBase dod) { DoDProperties.Add(new GridViewPropertyValueItem("Input Datasets")); DoDProperties.Add(new GridViewGCDProjectItem("New Surface", dod.NewSurface.Name, dod.NewSurface)); DoDProperties.Add(new GridViewGCDProjectItem("Old Surface", dod.OldSurface.Name, dod.OldSurface)); if (dod is DoDPropagated) { DoDPropagated dodProp = dod as DoDPropagated; DoDProperties.Add(new GridViewGCDProjectItem("New Error Surface", dodProp.NewError.Name, dodProp.NewError)); DoDProperties.Add(new GridViewGCDProjectItem("Old Error Surface", dodProp.OldError.Name, dodProp.OldError)); } if (dod.AOIMask == null) { DoDProperties.Add(new GridViewPropertyValueItem("Area Of Interest", dod.AOILabel)); } else { DoDProperties.Add(new GridViewGCDProjectItem("Area Of Interest", dod.AOILabel, dod.AOIMask)); } DoDProperties.Add(new GridViewPropertyValueItem("Input Parameters")); DoDProperties.Add(new GridViewPropertyValueItem("Uncertainty Analysis", dod.UncertaintyAnalysisLabel)); DoDProperties.Add(new GridViewPropertyValueItem("Output Datasets")); DoDProperties.Add(new GridViewPropertyValueItem("DoD Analysis Folder", ProjectManager.Project.GetRelativePath(dod.Folder.FullName))); DoDProperties.Add(new GridViewGCDProjectItem(dod.ThrDoD)); DoDProperties.Add(new GridViewGCDProjectItem(dod.RawDoD)); DoDProperties.Add(new GridViewPropertyValueItem("Intermediate Datasets")); if (dod is DoDPropagated) { DoDPropagated dodProp = dod as DoDPropagated; DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Propagated Error Raster", dodProp.PropagatedError))); if (dod is DoDProbabilistic) { DoDProbabilistic dodProb = dod as DoDProbabilistic; if (dodProb.SpatialCoherence == null) { DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Probability Raster", dodProb.PriorProbability))); } else { DoDProperties.Add(new GridViewPropertyValueItem("Spatial Coherence", string.Format("Bayesian updating with filter size of {0} X {0} cells", ((DoDProbabilistic)dod).SpatialCoherence.BufferSize))); DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Probability Raster", dodProb.PriorProbability))); DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Posterior Raster", dodProb.PosteriorProbability))); DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Conditional Raster", dodProb.ConditionalRaster))); DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Surface Lowering Count", dodProb.SpatialCoherenceErosion))); DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Surface Raising Count", dodProb.SpatialCoherenceDeposition))); } } } DoDProperties.Add(new GridViewGCDProjectItem(new DoDIntermediateRaster("Effective Threshold Surface", dod.ThrErr.Raster))); }
private void cmdMove(object sender, EventArgs e) { int original = lstDoDs.SelectedIndex; int moved = original + (string.Compare(((Control)sender).Name, "cmdMoveUp", true) == 0 ? -1 : 1); DoDBase dod = DoDs[original]; DoDs.Remove(dod); DoDs.Insert(moved, dod); lstDoDs.SelectedIndex = moved; }
public frmDoDResults(DoDBase dodItem) { InitializeComponent(); DoD = dodItem; m_Options = new DoDSummaryDisplayOptions(ProjectManager.Project.Units); ucProperties.Initialize(DoD); cmsChart = new UtilityForms.ChartContextMenu(DoD.Folder, "change_detection"); // Select the tab control to make it easy for user to quickly pan results tabProperties.Select(); }
public DoDGroup(TreeNodeCollection parentNodes, DoDBase dod, IContainer container) : base(parentNodes, dod.Name, string.Empty, "Change Detection", dod.Folder, container, true, 7) { DoD = dod; ContextMenuStrip.Items[0].Text = "Add Budget Segregation"; ContextMenuStrip.Items.Insert(0, new ToolStripMenuItem("View Change Detection Results", Properties.Resources.GCD, OnViewResults)); ContextMenuStrip.Items.Insert(3, new ToolStripMenuItem("Delete Change Detection", Properties.Resources.Delete, OnDelete)); ContextMenuStrip.Items.Insert(4, new ToolStripSeparator()); ContextMenuStrip.Items.Remove(ContextMenuStrip.Items.Find("AddToMap", false)[0]); ContextMenuStrip.Items.Insert(ContextMenuStrip.Items.Count - 2, new ToolStripMenuItem("Add Thresholded DoD Raster To Map", Properties.Resources.AddToMap, OnAddThrDoDToMap)); ContextMenuStrip.Items.Insert(ContextMenuStrip.Items.Count - 2, new ToolStripMenuItem("Add Raw DoD Raster To Map", Properties.Resources.AddToMap, OnAddRawDoDToMap)); ContextMenuStrip.Items.Insert(2, new ToolStripMenuItem("Add Linear Extraction From Profile Route", Properties.Resources.Add, OnLinear)); LoadChildNodes(); }
public BudgetSegregation Calculate(string dodName, DirectoryInfo analysisFolder, DoDBase dod, Project.Masks.AttributeFieldMask mask) { // Build the budget segregation result set object that will be returned. This determines paths BudgetSegregation bsResult = new BudgetSegregation(dodName, analysisFolder, mask, dod); // Retrieve the segregated statistics from the DoD rasters depending on the thresholding type used. Dictionary <string, GCDConsoleLib.GCD.DoDStats> results = null; if (dod is DoDMinLoD) { results = RasterOperators.GetStatsMinLoD(dod.RawDoD.Raster, ((DoDMinLoD)dod).Threshold, mask.Vector, mask._Field, ProjectManager.Project.Units, ProjectManager.OnProgressChange); } else { Raster propErr = ((DoDPropagated)dod).PropagatedError; if (dod is DoDProbabilistic) { results = RasterOperators.GetStatsProbalistic(dod.RawDoD.Raster, dod.ThrDoD.Raster, propErr, mask.Vector, mask._Field, ProjectManager.Project.Units, ProjectManager.OnProgressChange); } else { results = RasterOperators.GetStatsPropagated(dod.RawDoD.Raster, propErr, mask.Vector, mask._Field, ProjectManager.Project.Units, ProjectManager.OnProgressChange); } } // Retrieve the histograms for all budget segregation classes Dictionary <string, Histogram> rawHistos = RasterOperators.BinRaster(dod.RawDoD.Raster, DEFAULTHISTOGRAMNUMBER, mask.Vector, mask._Field, ProjectManager.OnProgressChange); Dictionary <string, Histogram> thrHistos = RasterOperators.BinRaster(dod.ThrDoD.Raster, DEFAULTHISTOGRAMNUMBER, mask.Vector, mask._Field, ProjectManager.OnProgressChange); decimal defaultBinWidth = 1; if (rawHistos.Count > 0) { defaultBinWidth = (decimal)rawHistos.Values.First().BinWidth(ProjectManager.Project.Units).As(ProjectManager.Project.Units.VertUnit); } // Make sure that the output folder and the folder for the figures exist analysisFolder.Create(); DoDBase.FiguresFolderPath(analysisFolder).Create(); // Build the output necessary output files int classIndex = 1; StringBuilder legendText = new StringBuilder("Class Index, Class Name"); foreach (KeyValuePair <string, GCDConsoleLib.GCD.DoDStats> segClass in results) { if (!rawHistos.ContainsKey(segClass.Key)) { rawHistos.Add(segClass.Key, new Histogram(DEFAULTHISTOGRAMNUMBER, defaultBinWidth)); } if (!thrHistos.ContainsKey(segClass.Key)) { thrHistos.Add(segClass.Key, new Histogram(DEFAULTHISTOGRAMNUMBER, defaultBinWidth)); } legendText.AppendLine(string.Format("{0},{1}", classIndex, segClass.Key)); string filePrefix = string.Format("c{0:000}", classIndex); FileInfo sumaryXML = new FileInfo(Path.Combine(analysisFolder.FullName, string.Format("{0}_summary.xml", filePrefix))); FileInfo rawHstPth = new FileInfo(Path.Combine(analysisFolder.FullName, string.Format("{0}_raw.csv", filePrefix))); FileInfo thrHstPth = new FileInfo(Path.Combine(analysisFolder.FullName, string.Format("{0}_thr.csv", filePrefix))); GenerateSummaryXML(segClass.Value, sumaryXML); GenerateChangeBarGraphicFiles(analysisFolder, segClass.Value, 600, 600, filePrefix); WriteHistogram(rawHistos[segClass.Key], rawHstPth); WriteHistogram(thrHistos[segClass.Key], thrHstPth); HistogramPair histograms = new HistogramPair(rawHistos[segClass.Key], rawHstPth, thrHistos[segClass.Key], thrHstPth); BudgetSegregationClass bsClass = new BudgetSegregationClass(segClass.Key, segClass.Value, histograms, sumaryXML); bsResult.Classes[segClass.Key] = bsClass; classIndex++; } // Generate the new inter-comparison spreadsheet FileInfo interCompare = new FileInfo(Path.Combine(analysisFolder.FullName, "InterCompare.xml")); try { InterComparison.Generate(results, interCompare); } catch (Exception ex) { // Do nothing. Essentially optional Console.WriteLine("Error generating inter-comparison as part of a budget segregation " + ex.Message); } // Write the class legend to file File.WriteAllText(bsResult.ClassLegend.FullName, legendText.ToString()); return(bsResult); }
public LinearExtractionFromDoD(XmlNode nodItem, DoDBase dod) : base(nodItem) { DoD = dod; }
public LinearExtractionFromDoD(string name, ProfileRoute route, FileInfo db, decimal sampleDistance, DoDBase dod) : base(name, route, db, sampleDistance) { DoD = dod; }
public frmBudgetSegProperties(DoDBase parentDoD) { // This call is required by the designer. InitializeComponent(); InitialDoD = parentDoD; }
private void cmdOK_Click(object sender, EventArgs e) { if (!ValidateForm()) { DialogResult = DialogResult.None; return; } try { Cursor = Cursors.WaitCursor; if (LinearExtraction == null) { GCDCore.Project.ProfileRoutes.ProfileRoute route = cboRoute.SelectedItem as GCDCore.Project.ProfileRoutes.ProfileRoute; ErrorSurface errSurf = null; List <GCDConsoleLib.Raster> rasters = new List <Raster>(); if (ElevationSurface is Surface) { rasters.Add(((Surface)ElevationSurface).Raster); if (cboError.SelectedItem is ErrorSurface) { errSurf = cboError.SelectedItem as ErrorSurface; rasters.Add(errSurf.Raster); } } else { DoDBase dod = ElevationSurface as DoDBase; rasters.Add(dod.ThrDoD.Raster); if (dod.ThrErr != null) { rasters.Add(dod.ThrErr.Raster); } } FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text); fiOutput.Directory.Create(); RasterOperators.LinearExtractor(route.Vector, rasters, fiOutput, valSampleDistance.Value, route.DistanceField, ProjectManager.OnProgressChange); GCDCore.Project.LinearExtraction.LinearExtraction le; if (ElevationSurface is DEMSurvey) { le = new GCDCore.Project.LinearExtraction.LinearExtractionFromDEM(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as DEMSurvey, errSurf); } else if (ElevationSurface is Surface) { le = new GCDCore.Project.LinearExtraction.LinearExtractionFromSurface(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as Surface, errSurf); } else { le = new GCDCore.Project.LinearExtraction.LinearExtractionFromDoD(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as DoDBase); } if (ElevationSurface is Surface) { ((Surface)ElevationSurface).LinearExtractions.Add(le); } else { ((DoDBase)ElevationSurface).LinearExtractions.Add(le); } } else { LinearExtraction.Name = txtName.Text; } ProjectManager.Project.Save(); Cursor = Cursors.Default; } catch (Exception ex) { GCDException.HandleException(ex, "Error performing linear extraction."); DialogResult = DialogResult.None; } }