Ejemplo n.º 1
0
        /// <summary>
        /// We separate out the calc op so we can call it from elsewhere (like the seggregation function)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id"></param>
        /// <param name="stats"></param>
        /// <param name="nodata"></param>
        public void CellChangeCalc(List <double[]> data, int id, DoDStats stats)
        {
            fDoDValue = data[0][id];
            fPropErr  = data[1][id];

            // Deposition
            if (fDoDValue > 0)
            {
                // Raw Deposition
                stats.DepositionRaw.AddToSumAndIncrementCounter(fDoDValue);

                if (fDoDValue > fPropErr)
                {
                    // Thresholded Deposition
                    stats.DepositionThr.AddToSumAndIncrementCounter(fDoDValue);
                    stats.DepositionErr.AddToSumAndIncrementCounter(fPropErr);
                }
            }
            // Erosion
            if (fDoDValue < 0)
            {
                // Raw Erosion
                stats.ErosionRaw.AddToSumAndIncrementCounter(fDoDValue * -1);

                if (fDoDValue < (fPropErr * -1))
                {
                    // Thresholded Erosion
                    stats.ErosionThr.AddToSumAndIncrementCounter(fDoDValue * -1);
                    stats.ErosionErr.AddToSumAndIncrementCounter(fPropErr);
                }
            }
        }
Ejemplo n.º 2
0
 public BudgetSegregationClass(string name, DoDStats stats, HistogramPair histograms, FileInfo summaryXML)
 {
     Name       = name;
     Statistics = stats;
     Histograms = histograms;
     SummaryXML = summaryXML;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rDod"></param>
 /// <param name="rErr"></param>
 /// <param name="theStats"></param>
 public GetDoDPropStats(Raster rDod, Raster rErr, DoDStats theStats) :
     base(new List <Raster> {
     rDod, rErr
 })
 {
     Stats = theStats;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This is the propError constructor
 /// </summary>
 /// <param name="rInput"></param>
 /// <param name="rMask"></param>
 /// <param name="theStats"></param>
 public GetChangeStats(Raster rInput, Raster rMask, DoDStats theStats) :
     base(new List <Raster> {
     rInput, rMask
 })
 {
     Stats = theStats;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rInput"></param>
 /// <param name="theStats"></param>
 public GetChangeStats(Raster rInput, DoDStats theStats) :
     base(new List <Raster> {
     rInput
 })
 {
     Stats   = theStats;
     _nodata = inNodataVals;
 }
Ejemplo n.º 6
0
        public void GetStatsMinLoDTest()
        {
            Raster rRaw    = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
            Raster rThresh = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));

            UnitGroup ug   = new UnitGroup(VolumeUnit.CubicMeter, AreaUnit.SquareMeter, LengthUnit.Meter, LengthUnit.Meter);
            DoDStats  test = RasterOperators.GetStatsMinLoD(rRaw, 73.0m, ug);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rawDoD"></param>
 /// <param name="thrDoD"></param>
 /// <param name="thresh"></param>
 /// <param name="theStats"></param>
 public GetDodMinLodStats(Raster rawDoD, decimal thresh, DoDStats theStats) :
     base(new List <Raster> {
     rawDoD
 })
 {
     Stats   = theStats;
     _thresh = (double)thresh;
 }
Ejemplo n.º 8
0
        public void GetStatsProbalisticTest()
        {
            Raster rTemp2005 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
            Raster rTemp2006 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));

            UnitGroup ug   = new UnitGroup(VolumeUnit.CubicMeter, AreaUnit.SquareMeter, LengthUnit.Meter, LengthUnit.Meter);
            DoDStats  test = RasterOperators.GetStatsProbalistic(rTemp2005, rTemp2006, rTemp2005, ug);
        }
Ejemplo n.º 9
0
        public void GetStatsPropagatedTest()
        {
            Raster rTemp2005 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
            Raster rTemp2006 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));

            // test the non-budget seg case
            UnitGroup ug    = new UnitGroup(VolumeUnit.CubicMeter, AreaUnit.SquareMeter, LengthUnit.Meter, LengthUnit.Meter);
            DoDStats  test1 = RasterOperators.GetStatsPropagated(rTemp2005, rTemp2006, ug);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="changeStats"></param>
        /// <returns></returns>
        /// <remarks>This method is needed by budget segregation as well</remarks>
        protected void GenerateSummaryXML(DoDStats changeStats, FileInfo outputPath)
        {
            string templatePath = Path.Combine(Project.ProjectManager.ExcelTemplatesFolder.FullName, "GCDSummary.xml");

            System.Text.StringBuilder outputText = default(System.Text.StringBuilder);

            try
            {
                using (System.IO.StreamReader objReader = new System.IO.StreamReader(templatePath))
                {
                    outputText = new System.Text.StringBuilder(objReader.ReadToEnd());
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error reading the GCD summary XML template file", ex);
                ex.Data["Excel Template Path"] = templatePath;
                throw ex2;
            }

            UnitsNet.Area             ca = Project.ProjectManager.Project.CellArea;
            UnitsNet.Units.LengthUnit lu = Project.ProjectManager.Project.Units.VertUnit;
            UnitsNet.Units.AreaUnit   au = Project.ProjectManager.Project.Units.ArUnit;
            UnitsNet.Units.VolumeUnit vu = Project.ProjectManager.Project.Units.VolUnit;
            string abbr = UnitsNet.Length.GetAbbreviation(lu);

            outputText.Replace("[LinearUnits]", abbr);

            outputText.Replace("[TotalAreaOfErosionRaw]", changeStats.ErosionRaw.GetArea(ca).As(au).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[TotalAreaOfErosionThresholded]", changeStats.ErosionThr.GetArea(ca).As(au).ToString(CultureInfo.InvariantCulture));

            outputText.Replace("[TotalAreaOfDepositionRaw]", changeStats.DepositionRaw.GetArea(ca).As(au).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[TotalAreaOfDepositionThresholded]", changeStats.DepositionThr.GetArea(ca).As(au).ToString(CultureInfo.InvariantCulture));

            outputText.Replace("[TotalVolumeOfErosionRaw]", changeStats.ErosionRaw.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[TotalVolumeOfErosionThresholded]", changeStats.ErosionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[ErrorVolumeOfErosion]", changeStats.ErosionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));

            outputText.Replace("[TotalVolumeOfDepositionRaw]", changeStats.DepositionRaw.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[TotalVolumeOfDepositionThresholded]", changeStats.DepositionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));
            outputText.Replace("[ErrorVolumeOfDeposition]", changeStats.DepositionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu).ToString(CultureInfo.InvariantCulture));

            try
            {
                using (StreamWriter objWriter = new StreamWriter(outputPath.FullName))
                {
                    objWriter.Write(outputText);
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error writing the GCD summary XML template file", ex);
                ex.Data["Excel Template Path"] = templatePath;
                throw ex2;
            }
        }
Ejemplo n.º 11
0
        public DoDBase Calculate(string dodName, DirectoryInfo analysisFolder, bool bBuildPyramids, UnitGroup units)
        {
            FileInfo rawDoDPath = BuildFilePath(analysisFolder, "raw", ProjectManager.RasterExtension);
            FileInfo thrDoDPath = BuildFilePath(analysisFolder, "thresh", ProjectManager.RasterExtension);
            FileInfo errDoDPath = BuildFilePath(analysisFolder, "threrr", ProjectManager.RasterExtension);
            FileInfo rawHstPath = BuildFilePath(analysisFolder, "raw", "csv");;
            FileInfo thrHstPath = BuildFilePath(analysisFolder, "thresh", "csv");
            FileInfo sumXMLPath = BuildFilePath(analysisFolder, "summary", "xml");

            analysisFolder.Create();

            // Subtract the new and old rasters to produce the raw DoD
            Raster rawDoD;

            if (AOIMask == null)
            {
                rawDoD = RasterOperators.Subtract(NewSurface.Raster, OldSurface.Raster, rawDoDPath, OnProgressChangeDoD);
            }
            else
            {
                rawDoD = RasterOperators.SubtractWithMask(NewSurface.Raster, OldSurface.Raster, AOIMask.Vector, rawDoDPath, OnProgressChangeDoD);
            }

            // Build pyraminds
            ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.DoDRaw, rawDoDPath);

            // Calculate the raw histogram
            Histogram rawHisto = RasterOperators.BinRaster(rawDoD, DEFAULTHISTOGRAMNUMBER, OnProgressChangeDoD);

            // Write the raw histogram
            WriteHistogram(rawHisto, rawHstPath);

            // Call the polymorphic method to threshold the DoD depending on the thresholding method
            Raster thrDoD = ThresholdRawDoD(rawDoD, thrDoDPath);

            // Build pyraminds for the thresholded raster
            ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.DoDThresholded, thrDoDPath);

            // Calculate the thresholded histogram
            Histogram thrHisto = RasterOperators.BinRaster(thrDoD, DEFAULTHISTOGRAMNUMBER, OnProgressChangeDoD);

            // Write the thresholded histogram
            WriteHistogram(thrHisto, thrHstPath);

            // Calculate the change statistics and write the output files
            DoDStats changeStats = CalculateChangeStats(rawDoD, thrDoD, units);

            GenerateSummaryXML(changeStats, sumXMLPath);
            GenerateChangeBarGraphicFiles(analysisFolder, changeStats, 0, 0);
            GenerateHistogramGraphicFiles(analysisFolder, rawHisto, thrHisto, 1920, 1080);

            // Calculate the thresholded error raster
            Raster errDoD = GenerateErrorRaster(errDoDPath);

            return(GetDoDResult(dodName, changeStats, rawDoD, thrDoD, errDoD, new HistogramPair(rawHisto, rawHstPath, thrHisto, thrHstPath), sumXMLPath));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Budget Seggregation Constructor
 /// </summary>
 /// <param name="rDod"></param>
 /// <param name="rErr"></param>
 /// <param name="theStats"></param>
 /// <param name="PolygonMask"></param>
 /// <param name="FieldName"></param>
 public GetDoDPropStats(Raster rDod, Raster rErr, DoDStats theStats, Vector PolygonMask,
                        string FieldName) :
     base(new List <Raster> {
     rDod, rErr
 }, PolygonMask)
 {
     Stats      = theStats;
     SegStats   = new Dictionary <string, DoDStats>();
     _fieldname = FieldName;
 }
Ejemplo n.º 13
0
        public BudgetSegregationClass(XmlNode nodClass)
        {
            Name = nodClass.SelectSingleNode("Name").InnerText;
            FileInfo rawHist = ProjectManager.Project.GetAbsolutePath(nodClass.SelectSingleNode("RawHistogram").InnerText);
            FileInfo thrHist = ProjectManager.Project.GetAbsolutePath(nodClass.SelectSingleNode("ThrHistogram").InnerText);

            Histograms = new HistogramPair(rawHist, thrHist);
            SummaryXML = ProjectManager.Project.GetAbsolutePath(nodClass.SelectSingleNode("SummaryXML").InnerText);
            Statistics = DoDBase.DeserializeStatistics(nodClass.SelectSingleNode("Statistics"), ProjectManager.Project.CellArea, ProjectManager.Project.Units);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// This is the Budget Seggregation with propError Constructor using a VECTOR mask only
 /// </summary>
 /// <param name="rInput"></param>
 /// <param name="rPropError"></param>
 /// <param name="theStats"></param>
 /// <param name="PolygonMask"></param>
 /// <param name="FieldName"></param>
 public GetChangeStats(Raster rInput, Raster rPropError, DoDStats theStats, Vector PolygonMask, string FieldName) :
     base(new List <Raster> {
     rInput, rPropError
 }, PolygonMask)
 {
     // Note hwo the polymask gets passed to the base. This is so we can filter to shapes that
     // overlap the chunks to speed things up.
     Stats      = theStats;
     SegStats   = new Dictionary <string, DoDStats>();
     _fieldname = FieldName;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Budget Seggregation constructor
 /// </summary>
 /// <param name="rawDoD"></param>
 /// <param name="thrDoD"></param>
 /// <param name="thresh"></param>
 /// <param name="theStats"></param>
 /// <param name="PolygonMask"></param>
 /// <param name="FieldName"></param>
 public GetDodMinLodStats(Raster rawDoD,
                          decimal thresh, DoDStats theStats, Vector PolygonMask, string FieldName) :
     base(new List <Raster> {
     rawDoD
 }, PolygonMask)
 {
     Stats      = theStats;
     _thresh    = (double)thresh;
     SegStats   = new Dictionary <string, DoDStats>();
     _fieldname = FieldName;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// This is the Budget Seggregation with propError Constructor using a raster mask
        /// </summary>
        /// <param name="rInput"></param>
        /// <param name="rPropError"></param>
        /// <param name="theStats"></param>
        /// <param name="PolygonMask"></param>
        /// <param name="FieldName"></param>
        public GetChangeStats(Raster rInput, Raster rPropError, DoDStats theStats,
                              VectorRaster rPolygonMask, string FieldName) :
            base(new List <Raster> {
            rInput, rPropError
        }, rPolygonMask)
        {
            Stats    = theStats;
            SegStats = new Dictionary <string, DoDStats>();

            _rasterVectorFieldVals = rPolygonMask.FieldValues;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Rasterized Vector Budget Seggregation constructor
        /// </summary>
        /// <param name="rawDoD"></param>
        /// <param name="thrDoD"></param>
        /// <param name="thresh"></param>
        /// <param name="theStats"></param>
        /// <param name="PolygonMask"></param>
        /// <param name="FieldName"></param>
        public GetDodMinLodStats(Raster rawDoD,
                                 decimal thresh, DoDStats theStats, VectorRaster rPolymask, string FieldName) :
            base(new List <Raster> {
            rawDoD
        }, rPolymask)
        {
            Stats    = theStats;
            _thresh  = (double)thresh;
            SegStats = new Dictionary <string, DoDStats>();

            _rasterVectorFieldVals = rPolymask.FieldValues;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Budget Seggregation Constructor with RASTERized vector mask
        /// </summary>
        /// <param name="rDod"></param>
        /// <param name="rErr"></param>
        /// <param name="theStats"></param>
        /// <param name="rPolymask"></param>
        /// <param name="vPolygonMask"></param>
        /// <param name="FieldName"></param>
        public GetDoDPropStats(Raster rDod, Raster rErr, DoDStats theStats, VectorRaster rPolymask,
                               string FieldName) :
            base(new List <Raster> {
            rDod, rErr
        }, rPolymask)
        {
            Stats      = theStats;
            SegStats   = new Dictionary <string, DoDStats>();
            _fieldname = FieldName;

            _rasterVectorFieldVals = rPolymask.FieldValues;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Budget Seggregation constructor using a raster mask
        /// </summary>
        /// <param name="rInput"></param>
        /// <param name="theStats"></param>
        /// <param name="PolygonMask"></param>
        /// <param name="FieldName"></param>
        public GetChangeStats(Raster rInput, DoDStats theStats, VectorRaster rPolygonMask,
                              string FieldName) :
            base(new List <Raster> {
            rInput
        }, rPolygonMask)
        {
            // Note how we don't pass the vector into the base. We're not going to do anything
            // with the geometry of the shapefile.
            Stats    = theStats;
            SegStats = new Dictionary <string, DoDStats>();

            _rasterVectorFieldVals = rPolygonMask.FieldValues;
        }
        protected override DoDBase GetDoDResult(string dodName, DoDStats changeStats, Raster rawDoD, Raster thrDoD, Raster thrErr, HistogramPair histograms, FileInfo summaryXML)
        {
            bool bBayesian = SpatialCoherence is CoherenceProperties;
            int  nFilter   = 0;

            if (SpatialCoherence is CoherenceProperties)
            {
                nFilter = SpatialCoherence.BufferSize;
            }

            return(new DoDProbabilistic(dodName, rawDoD.GISFileInfo.Directory, NewSurface, OldSurface, AOIMask, histograms, summaryXML, rawDoD, thrDoD, thrErr, NewError, OldError,
                                        PropagatedErrRaster, m_PriorProbRaster, m_PosteriorRaster, m_ConditionalRaster, m_SpatialCoErosionRaster, m_SpatialCoDepositionRaster,
                                        SpatialCoherence, Threshold, changeStats));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// We separate out the calc op so we can call it from elsewhere (like the seggregation function)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id"></param>
        /// <param name="stats"></param>
        /// <param name="nodata"></param>
        public void CellChangeCalc(List <double[]> data, int id, DoDStats stats)
        {
            double fRVal, fMask;

            int rasterCount = data.Count;

            // We need to discount the rastermask
            if (_hasRasterizedPolymask)
            {
                rasterCount--;
            }

            // If we don't have a mask to use then do it this way
            if (rasterCount == 1 && data[0][id] != inNodataVals[0])
            {
                fRVal = data[0][id];
                // Deposition
                if (fRVal > 0)
                {
                    stats.DepositionRaw.AddToSumAndIncrementCounter(fRVal);
                }
                // Erosion
                else if (fRVal < 0)
                {
                    stats.ErosionRaw.AddToSumAndIncrementCounter(fRVal * -1);
                }
            }

            // If we have an error mask then use it.
            else if (rasterCount == 2 && data[1][id] != inNodataVals[1])
            {
                fRVal = data[0][id];
                fMask = data[1][id];
                if (fRVal > 0)
                {
                    if (fMask != inNodataVals[1])
                    {
                        if (fMask > 0) // Deposition
                        {
                            stats.DepositionRaw.AddToSumAndIncrementCounter(fRVal);
                        }
                        else if (fMask < 0) // Erosion
                        {
                            stats.ErosionRaw.AddToSumAndIncrementCounter(fRVal);
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
 protected DoDBase(string name, DirectoryInfo folder, Surface newSurface, Surface oldSurface, Masks.AOIMask aoi, Raster rawDoD, Raster thrDoD, Raster thrErr, HistogramPair histograms, FileInfo summaryXML, DoDStats stats)
     : base(name)
 {
     Folder             = folder;
     NewSurface         = newSurface;
     OldSurface         = oldSurface;
     AOIMask            = aoi;
     RawDoD             = new DoDRaster(string.Format(Name + " - Raw"), rawDoD);
     ThrDoD             = new DoDRaster(string.Format(Name + " - Thresholded"), thrDoD);
     ThrErr             = new DoDRaster(string.Format(Name + " - Thresholded Error"), thrErr);
     Histograms         = histograms;
     SummaryXML         = summaryXML;
     Statistics         = stats;
     BudgetSegregations = new List <BudgetSegregation>();
     LinearExtractions  = new List <LinearExtraction.LinearExtraction>();
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Using a Rasterized vector to run a budget seggregation op
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id"></param>
        private void RasterBudgetSegCellOp(List <double[]> data, int id)
        {
            double rPolymaskVal = data[_inputRasters.Count - 1][id];

            if (rPolymaskVal != inNodataVals[_inputRasters.Count - 1])
            {
                string fldVal = _rasterVectorFieldVals[(int)rPolymaskVal];
                // Create a new DoDStats object if we don't already have one
                if (!SegStats.ContainsKey(fldVal))
                {
                    SegStats[fldVal] = new DoDStats(Stats);
                }

                CellChangeCalc(data, id, SegStats[fldVal]);
            }
        }
Ejemplo n.º 24
0
        public DoDProbabilistic(string name, DirectoryInfo folder, Surface newSurface, Surface oldSurface, Project.Masks.AOIMask aoi, HistogramPair histograms, FileInfo summaryXML,
                                Raster rawDoD, Raster thrDoD, Raster thrErr,
                                ErrorSurface newError, ErrorSurface oldError, Raster propErr, FileInfo priorProb,
                                FileInfo postProb, FileInfo cond, FileInfo spatCoEr, FileInfo spatCoDep, CoherenceProperties spatCoProps,
                                decimal confidenceLevel, DoDStats stats)
            : base(name, folder, newSurface, oldSurface, aoi, rawDoD, thrDoD, thrErr, histograms, summaryXML, newError, oldError, propErr, stats)
        {
            ConfidenceLevel  = confidenceLevel;
            PriorProbability = new Raster(priorProb);

            if (spatCoProps != null)
            {
                PosteriorProbability       = new Raster(postProb);
                ConditionalRaster          = new Raster(cond);
                SpatialCoherenceErosion    = new Raster(spatCoEr);
                SpatialCoherenceDeposition = new Raster(spatCoDep);
                SpatialCoherence           = spatCoProps;
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// The budget seggregator looks to see if a cell is inside any of the features
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id"></param>
        private void VectorBudgetSegCellOp(List <double[]> data, int id)
        {
            if (_shapemask.Count > 0)
            {
                decimal[]     ptcoords = ChunkExtent.Id2XY(id);
                List <string> shapes   = _polymask.ShapesContainPoint((double)ptcoords[0], (double)ptcoords[1], _fieldname, _shapemask);
                if (shapes.Count > 0)
                {
                    foreach (string fldVal in shapes)
                    {
                        if (!SegStats.ContainsKey(fldVal))
                        {
                            SegStats[fldVal] = new DoDStats(Stats);
                        }

                        CellChangeCalc(data, id, SegStats[fldVal]);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        protected DoDBase(XmlNode nodDoD)
            : base(nodDoD.SelectSingleNode("Name").InnerText)
        {
            Folder     = ProjectManager.Project.GetAbsoluteDir(nodDoD.SelectSingleNode("Folder").InnerText);
            NewSurface = DeserializeSurface(nodDoD, "NewSurface");
            OldSurface = DeserializeSurface(nodDoD, "OldSurface");

            XmlNode nodAOI = nodDoD.SelectSingleNode("AOI");

            if (nodAOI is XmlNode)
            {
                AOIMask = ProjectManager.Project.Masks.First(x => string.Compare(x.Name, nodAOI.InnerText, true) == 0) as Masks.AOIMask;
            }

            RawDoD     = new DoDRaster(string.Format(Name + " - Raw"), ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("RawDoD").InnerText));
            ThrDoD     = new DoDRaster(string.Format(Name + " - Thresholded"), ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("ThrDoD").InnerText));
            ThrErr     = new DoDRaster(string.Format(Name + " - Thresholded Error"), ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("ThrErr").InnerText));
            Histograms = new HistogramPair(ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("RawHistogram").InnerText),
                                           ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("ThrHistogram").InnerText));
            SummaryXML = ProjectManager.Project.GetAbsolutePath(nodDoD.SelectSingleNode("SummaryXML").InnerText);
            Statistics = DeserializeStatistics(nodDoD.SelectSingleNode("Statistics"), ProjectManager.Project.CellArea, ProjectManager.Project.Units);

            BudgetSegregations = new List <BudgetSegregation>();
            XmlNode nodBSes = nodDoD.SelectSingleNode("BudgetSegregations");

            if (nodBSes is XmlNode)
            {
                foreach (XmlNode nodBS in nodBSes.SelectNodes("BudgetSegregation"))
                {
                    BudgetSegregation bs = new BudgetSegregation(nodBS, this);
                    BudgetSegregations.Add(bs);
                }
            }

            LinearExtractions = new List <LinearExtraction.LinearExtraction>();
            foreach (XmlNode nodLE in nodDoD.SelectNodes("LinearExtractions/LinearExtraction"))
            {
                LinearExtraction.LinearExtraction le = new LinearExtraction.LinearExtractionFromDoD(nodLE, this);
                LinearExtractions.Add(le);
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Constructor for change detection engine
 /// </summary>
 /// <param name="name"></param>
 /// <param name="folder"></param>
 /// <param name="newSurface"></param>
 /// <param name="oldSurface"></param>
 /// <param name="rawDoD"></param>
 /// <param name="thrDoD"></param>
 /// <param name="rawHist"></param>
 /// <param name="thrHist"></param>
 /// <param name="threshold"></param>
 /// <param name="stats"></param>
 public DoDMinLoD(string name, DirectoryInfo folder, Surface newSurface, Surface oldSurface, Project.Masks.AOIMask aoi, Raster rawDoD, Raster thrDoD, Raster thrErr, HistogramPair histograms, FileInfo summaryXML, decimal threshold, DoDStats stats)
     : base(name, folder, newSurface, oldSurface, aoi, rawDoD, thrDoD, thrErr, histograms, summaryXML, stats)
 {
     Threshold = threshold;
 }
Ejemplo n.º 28
0
        public static void SerializeDoDStatistics(XmlDocument xmlDoc, XmlNode nodParent, DoDStats stats)
        {
            XmlNode nodErosion = nodParent.AppendChild(xmlDoc.CreateElement("Erosion"));

            SerializeAreaVolume(xmlDoc, nodErosion.AppendChild(xmlDoc.CreateElement("Raw")), stats.ErosionRaw, stats.StatsUnits, stats.CellArea);
            SerializeAreaVolume(xmlDoc, nodErosion.AppendChild(xmlDoc.CreateElement("Thresholded")), stats.ErosionThr, stats.StatsUnits, stats.CellArea);
            nodErosion.AppendChild(xmlDoc.CreateElement("Error")).AppendChild(xmlDoc.CreateElement("Volume")).InnerText =
                stats.ErosionErr.GetVolume(stats.CellArea, stats.StatsUnits.VertUnit).As(stats.StatsUnits.VolUnit).ToString("R");

            XmlNode nodDeposition = nodParent.AppendChild(xmlDoc.CreateElement("Deposition"));

            SerializeAreaVolume(xmlDoc, nodDeposition.AppendChild(xmlDoc.CreateElement("Raw")), stats.DepositionRaw, stats.StatsUnits, stats.CellArea);
            SerializeAreaVolume(xmlDoc, nodDeposition.AppendChild(xmlDoc.CreateElement("Thresholded")), stats.DepositionThr, stats.StatsUnits, stats.CellArea);
            nodDeposition.AppendChild(xmlDoc.CreateElement("Error")).AppendChild(xmlDoc.CreateElement("Volume")).InnerText =
                stats.DepositionErr.GetVolume(stats.CellArea, stats.StatsUnits.VertUnit).As(stats.StatsUnits.VolUnit).ToString("R");
        }
Ejemplo n.º 29
0
 protected abstract DoDBase GetDoDResult(string dodName, DoDStats changeStats, Raster rawDoD, Raster thrDoD, Raster errDoDPath, HistogramPair histograms, FileInfo summaryXML);
Ejemplo n.º 30
0
        protected void GenerateChangeBarGraphicFiles(DirectoryInfo analysisFolder, DoDStats stats, int fChartWidth, int fChartHeight, string sFilePrefix = "")
        {
            ElevationChangeBarViewer barViewer = new ElevationChangeBarViewer();

            if (!string.IsNullOrEmpty(sFilePrefix))
            {
                if (!sFilePrefix.EndsWith("_"))
                {
                    sFilePrefix += "_";
                }
            }

            DirectoryInfo figuresFolder = Project.DoDBase.FiguresFolderPath(analysisFolder);

            figuresFolder.Create();

            UnitsNet.Area             ca = GCDCore.Project.ProjectManager.Project.CellArea;
            UnitsNet.Units.LengthUnit lu = Project.ProjectManager.Project.Units.VertUnit;
            UnitsNet.Units.AreaUnit   au = Project.ProjectManager.Project.Units.ArUnit;
            UnitsNet.Units.VolumeUnit vu = Project.ProjectManager.Project.Units.VolUnit;
            string abbr = UnitsNet.Length.GetAbbreviation(lu);

            barViewer.Refresh(
                stats.ErosionThr.GetArea(ca).As(au),
                stats.DepositionThr.GetArea(ca).As(au), abbr, ElevationChangeBarViewer.BarTypes.Area, true);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_AreaAbsolute.png")), fChartWidth, fChartHeight);

            barViewer.Refresh(
                stats.ErosionThr.GetArea(ca).As(au),
                stats.DepositionThr.GetArea(ca).As(au), abbr, ElevationChangeBarViewer.BarTypes.Area, false);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_AreaRelative.png")), fChartWidth, fChartHeight);

            barViewer.Refresh(
                stats.ErosionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.DepositionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.NetVolumeOfDifference_Thresholded.As(vu),
                stats.ErosionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.DepositionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.NetVolumeOfDifference_Error.As(vu), abbr, ElevationChangeBarViewer.BarTypes.Volume, true);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_VolumeAbsolute.png")), fChartWidth, fChartHeight);

            barViewer.Refresh(
                stats.ErosionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.DepositionThr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.NetVolumeOfDifference_Thresholded.As(vu),
                stats.ErosionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.DepositionErr.GetVolume(ca, Project.ProjectManager.Project.Units).As(vu),
                stats.NetVolumeOfDifference_Error.As(vu), abbr, ElevationChangeBarViewer.BarTypes.Volume, false);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_VolumeRelative.png")), fChartWidth, fChartHeight);

            barViewer.Refresh(
                stats.AverageDepthErosion_Thresholded.As(lu),
                stats.AverageDepthDeposition_Thresholded.As(lu),
                stats.AverageNetThicknessOfDifferenceADC_Thresholded.As(lu),
                stats.AverageDepthErosion_Error.As(lu),
                stats.AverageDepthDeposition_Error.As(lu),
                stats.AverageThicknessOfDifferenceADC_Error.As(lu), abbr, ElevationChangeBarViewer.BarTypes.Vertical, true);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_DepthAbsolute.png")), fChartWidth, fChartHeight);

            barViewer.Refresh(
                stats.AverageDepthErosion_Thresholded.As(lu),
                stats.AverageDepthDeposition_Thresholded.As(lu),
                stats.AverageNetThicknessOfDifferenceADC_Thresholded.As(lu),
                stats.AverageDepthErosion_Error.As(lu),
                stats.AverageDepthDeposition_Error.As(lu),
                stats.AverageThicknessOfDifferenceADC_Error.As(lu), abbr, ElevationChangeBarViewer.BarTypes.Vertical, false);
            barViewer.Save(new FileInfo(Path.Combine(figuresFolder.FullName, sFilePrefix + "ChangeBars_DepthRelative.png")), fChartWidth, fChartHeight);
        }