コード例 #1
0
        public void MathTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTempl = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const900.tif")));
                Raster rTemp2 = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const950.tif")));

                Raster rOld = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));
                Raster rNew = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\2006FebDEM.tif")));

                Raster rAdd1 = RasterOperators.Add(rTempl, 2.1m, new FileInfo(Path.Combine(tmp.Name, "RasterAddOperand.tif")));
                Raster rAdd2 = RasterOperators.Add(rTempl, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterAddRaster.tif")));

                Raster rSub1 = RasterOperators.Subtract(rTempl, 2.1m, new FileInfo(Path.Combine(tmp.Name, "RasterSubtractOperand.tif")));
                Raster rSub2 = RasterOperators.Subtract(rTempl, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterSubtractRaster.tif")));

                // Do another real DoD for luck
                Raster rSub3 = RasterOperators.Subtract(rNew, rOld, new FileInfo(Path.Combine(tmp.Name, "RasterSubtractRasterDoD.tif")));

                Raster rMult1 = RasterOperators.Multiply(rTempl, 2.1m, new FileInfo(Path.Combine(tmp.Name, "RasterMultiplyOperand.tif")));
                Raster rMult2 = RasterOperators.Multiply(rTempl, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterMultiplyRaster.tif")));

                Raster rDiv1 = RasterOperators.Divide(rTempl, 2.1m, new FileInfo(Path.Combine(tmp.Name, "RasterDivideOperand.tif")));
                Raster rDiv2 = RasterOperators.Divide(rTempl, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterDivideRaster.tif")));
            }
        }
コード例 #2
0
        public void PosteriorProbabilityTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                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")));
                Raster rDoD      = RasterOperators.Subtract(rTemp2006, rTemp2005, new FileInfo(Path.Combine(tmp.Name, "rDoD.tif")));

                Raster GCDErosion1    = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.Erosion, 1, new FileInfo(Path.Combine(tmp.Name, "Erosion1.tif")));
                Raster GCDDeposition1 = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.Deposition, 1, new FileInfo(Path.Combine(tmp.Name, "Deposition1.tif")));
                Raster GCDAll1        = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.All, 1, new FileInfo(Path.Combine(tmp.Name, "All1.tif")));

                ErrorRasterProperties props02 = new ErrorRasterProperties(0.2m);
                ErrorRasterProperties props01 = new ErrorRasterProperties(0.1m);
                // min 60% => 5 // max 100% => 9

                // 0.1 2006
                // 0.2 2005
                Raster r2005Error = RasterOperators.CreateErrorRaster(rTemp2005, props02, new FileInfo(Path.Combine(tmp.Name, "2005Dec_DEM_CONSTERR02.tif")));
                Raster r2006Error = RasterOperators.CreateErrorRaster(rTemp2006, props01, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));

                Raster propError = RasterOperators.RootSumSquares(r2006Error, r2005Error, new FileInfo(Path.Combine(tmp.Name, "properror.tif")));
                Raster postProb  = RasterOperators.CreatePriorProbabilityRaster(rDoD, propError, new FileInfo(Path.Combine(tmp.Name, "priorprob.tif")));

                Raster PostProb = RasterOperators.PosteriorProbability(rDoD, postProb, GCDErosion1, GCDDeposition1, new FileInfo(Path.Combine(tmp.Name, "postprob.tif")), new FileInfo(Path.Combine(tmp.Name, "cond.tif")), 5, 9);
            }
        }
コード例 #3
0
        public void CreateErrorRasterFis()
        {
            Raster   rOld    = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));
            Raster   rNew    = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\2006FebDEM.tif")));
            FileInfo fisFile = new FileInfo(DirHelpers.GetTestRootPath(@"FIS\FuzzyChinookJuvenile_03.fis"));

            // And now the budget seg case
            Vector vPolyMask = new Vector(new FileInfo(DirHelpers.GetTestRootPath(@"SulphurGCDMASK\Sulphur_SimpleGCDMask.shp")));

            using (ITempDir tmp = TempDir.Create())
            {
                FileInfo fiPolyMaskCopy = new FileInfo(Path.Combine(tmp.Name, "Sulphur_SimpleGCDMask.shp"));
                vPolyMask.Copy(fiPolyMaskCopy);
                Vector vPolyMaskCopy = new Vector(fiPolyMaskCopy);

                Dictionary <string, Raster> fisinputs = new Dictionary <string, Raster>()
                {
                    { "Depth", rOld },
                    { "Velocity", rNew },
                    { "GrainSize_mm", rOld }
                };

                Dictionary <string, ErrorRasterProperties> props = new Dictionary <string, ErrorRasterProperties>
                {
                    { "LiDAR", new ErrorRasterProperties(0.1m) },
                    { "Total Station", new ErrorRasterProperties(0.2m) },
                    { "Unknown", new ErrorRasterProperties(fisFile, fisinputs) }
                };


                Raster r2006Error = RasterOperators.CreateErrorRaster(rOld, vPolyMaskCopy, "Method", props, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));
            }
        }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rawDoD"></param>
 /// <param name="thrDoDPath"></param>
 /// <returns></returns>
 /// <remarks>Let the base class build the pyramids for the thresholded raster</remarks>
 protected override Raster ThresholdRawDoD(Raster rawDoD, FileInfo thrDoDPath)
 {
     return(RasterOperators.SetNull(rawDoD, RasterOperators.ThresholdOps.GreaterThanOrEqual, -Threshold,
                                    RasterOperators.ThresholdOps.LessThanOrEqual,
                                    Threshold, thrDoDPath,
                                    OnProgressChangeDoD));
 }
コード例 #5
0
        public void ExtendedCopyTest()
        {
            // First try it with a real file
            using (ITempDir tmp = TempDir.Create())
            {
                Raster          rTempl          = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("Slopey950-980.tif")));
                ExtentRectangle newExtReal      = rTempl.Extent.Buffer(15);
                Raster          rTemplateOutput = RasterOperators.ExtendedCopy(rTempl, new FileInfo(Path.Combine(tmp.Name, "ExtendedCopyRasterTestBuffer.tif")), newExtReal);

                ExtentRectangle newExtReal2 = rTempl.Extent.Buffer(5);
                newExtReal2.Rows = (int)newExtReal2.Rows / 2;
                newExtReal2.Cols = (int)newExtReal2.Cols / 3;
                Raster rTemplateOutput2 = RasterOperators.ExtendedCopy(rTempl, new FileInfo(Path.Combine(tmp.Name, "ExtendedCopyRasterTestSlice.tif")), newExtReal2);
            }

            Raster Raster1 = new FakeRaster <int>(10, 20, -1, 1, new int[, ] {
                { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }
            });

            int[,] outgrid = new int[7, 8];
            outgrid.Fill(-999);
            Raster rOutput = new FakeRaster <int>(10, 20, -1, 1, outgrid);

            ExtentRectangle newExt = Raster1.Extent.Buffer(2);

            Internal.Operators.ExtendedCopy <int> copyOp = new Internal.Operators.ExtendedCopy <int>(Raster1, rOutput, new ExtentRectangle(newExt));
            copyOp.RunWithOutput();
        }
コード例 #6
0
        public void LinearExtractorTest()
        {
            Raster rDetrended = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"ExtractorTest\Detrended.tif")));
            Raster rWSEDEM    = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"ExtractorTest\WSEDEM.tif")));

            Vector centerline = new Vector(new FileInfo(DirHelpers.GetTestRootPath(@"ExtractorTest\BCenterline.shp")));
            Vector xs         = new Vector(new FileInfo(DirHelpers.GetTestRootPath(@"ExtractorTest\BCrossSections.shp")));

            using (ITempDir tmp = TempDir.Create())
            {
                //FileInfo centerlinecsv = new FileInfo(Path.Combine(tmp.Name, "centerline.csv"));
                //FileInfo xscsv = new FileInfo(Path.Combine(tmp.Name, "xs.csv"));

                //FileInfo centerlinecsv = new FileInfo(@"c:\dev\CSV\centerline.csv");
                //FileInfo xscsv = new FileInfo(@"c:\dev\CSV\xs.csv");

                //RasterOperators.LinearExtractor(xs, new List<Raster> { rDetrended, rWSEDEM }, xscsv);
                //RasterOperators.LinearExtractor(centerline, new List<Raster> { rDetrended, rWSEDEM }, centerlinecsv);

                FileInfo centerlinecsv1mFIELD = new FileInfo(Path.Combine(tmp.Name, "centerline1mFIELD.csv"));
                FileInfo xscsv1mFIELD         = new FileInfo(Path.Combine(tmp.Name, "xs1mFIELD.csv"));
                FileInfo xscsv1mNoFIELD       = new FileInfo(Path.Combine(tmp.Name, "xs1mNoField.csv"));

                RasterOperators.LinearExtractor(xs, new List <Raster> {
                    rDetrended, rWSEDEM
                }, xscsv1mFIELD, 1.0m, "IsValid");
                RasterOperators.LinearExtractor(xs, new List <Raster> {
                    rDetrended, rWSEDEM
                }, xscsv1mNoFIELD, 1.0m);
                RasterOperators.LinearExtractor(centerline, new List <Raster> {
                    rDetrended, rWSEDEM
                }, centerlinecsv1mFIELD, 1.0m, "CLID");
            }
        }
コード例 #7
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);
        }
コード例 #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);
        }
コード例 #9
0
 public void UniformTest()
 {
     using (ITempDir tmp = TempDir.Create())
     {
         Raster rTempl           = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("AngledSlopey950-980E.tif")));
         Raster rTemplateOutput1 = RasterOperators.Uniform <int>(rTempl, new FileInfo(Path.Combine(tmp.Name, "UniformTest.tif")), 7);
     }
 }
コード例 #10
0
        protected override Raster ThresholdRawDoD(Raster rawDoD, FileInfo thrDoDPath)
        {
            GeneratePropagatedErrorRaster(thrDoDPath.Directory);
            Raster thrDoD = RasterOperators.AbsoluteSetNull(rawDoD, RasterOperators.ThresholdOps.GreaterThan, PropagatedErrRaster, thrDoDPath,
                                                            OnProgressChangeDoD);

            return(thrDoD);
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        /// <remarks>Calculate the propograted error raster based on the two error surfaces. Then threshold the raw
        /// DoD removing any cells that have a value less than the propogated error.</remarks>
        protected void GeneratePropagatedErrorRaster(DirectoryInfo analysisFolder)
        {
            FileInfo propErrPath = BuildFilePath(analysisFolder, "PropErr", ProjectManager.RasterExtension);

            PropagatedErrRaster = RasterOperators.RootSumSquares(NewError.Raster, OldError.Raster, propErrPath, OnProgressChangeDoD);

            // Build Pyramids
            ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.PropagatedError, propErrPath);
        }
コード例 #12
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);
        }
コード例 #13
0
 public void RootSumSquaresTest()
 {
     using (ITempDir tmp = TempDir.Create())
     {
         Raster rTempl           = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const900.tif")));
         Raster rTemp2           = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const950.tif")));
         Raster rTemplateOutput2 = RasterOperators.RootSumSquares(rTempl, rTemp2, new FileInfo(Path.Combine(tmp.Name, "FISTest.tif")));
     }
 }
コード例 #14
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));
        }
コード例 #15
0
 public void BuildPyramidsInterfaceTest()
 {
     using (ITempDir tmp = TempDir.Create())
     {
         Raster          rTempl          = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("AngledSlopey950-980E.tif")));
         ExtentRectangle newExtReal      = rTempl.Extent.Buffer(15);
         Raster          rTemplateOutput = RasterOperators.ExtendedCopy(rTempl, new FileInfo(Path.Combine(tmp.Name, "PyramidTest.tif")), newExtReal);
         RasterOperators.BuildPyramids(new FileInfo(Path.Combine(tmp.Name, "PyramidTest.tif")));
     }
 }
コード例 #16
0
        public void SlopeHillshadeTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTempl = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"PointDensity\SulpherCreek\2006Feb_DEM.img")));

                Raster rTemplateOutput1 = RasterOperators.SlopeDegrees(rTempl, new FileInfo(Path.Combine(tmp.Name, "SlopeDegrees.tif")));
                Raster rTemplateOutput2 = RasterOperators.SlopePercent(rTempl, new FileInfo(Path.Combine(tmp.Name, "SlopePercent.tif")));
                Raster rTemplateOutput3 = RasterOperators.Hillshade(rTempl, new FileInfo(Path.Combine(tmp.Name, "Hillshade.tif")));
            }
        }
コード例 #17
0
 public void MosaicTest()
 {
     using (ITempDir tmp = TempDir.Create())
     {
         List <FileInfo> theList = new List <FileInfo>()
         {
             new FileInfo(DirHelpers.GetTestRasterPath("const900.tif")),
             new FileInfo(DirHelpers.GetTestRasterPath("const950.tif"))
         };
         Raster rTemplateOutput2 = RasterOperators.Mosaic(theList, new FileInfo(Path.Combine(tmp.Name, "FISTest.tif")));
     }
 }
コード例 #18
0
        public void BilinearResampleTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster          rTempl     = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("AngledSlopey950-980E.tif")));
                ExtentRectangle newExtReal = new ExtentRectangle(rTempl.Extent);
                newExtReal.CellHeight = newExtReal.CellHeight * 2;
                newExtReal.CellWidth  = newExtReal.CellWidth * 2;

                Raster rTemplateOutput = RasterOperators.BilinearResample(rTempl, new FileInfo(Path.Combine(tmp.Name, "BilinearResample.tif")), newExtReal);
                Debug.WriteLine("Test Done");
            }
        }
コード例 #19
0
        protected override Raster GenerateErrorRaster(FileInfo thrErrorPath)
        {
            double zvalDbl = GCDConsoleLib.Utility.Probability.ltqnorm((double)Threshold);

            decimal zval = decimal.MinValue;

            if (!(double.IsNegativeInfinity(zvalDbl) || double.IsPositiveInfinity(zvalDbl)))
            {
                zval = (decimal)zvalDbl;
            }

            return(RasterOperators.Multiply(PropagatedErrRaster, zval, thrErrorPath, OnProgressChangeDoD));
        }
コード例 #20
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ucName.ValidateForm() || !ucErrProps.ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (chkDefault.Checked && DEM.ErrorSurfaces.Count > 0)
                {
                    // Need to set all other error surfaces to not be the default
                    DEM.ErrorSurfaces.ToList().ForEach(x => x.IsDefault = false);
                }

                if (ErrorSurface == null)
                {
                    // If this is a FIS error surface then copy the FIS file to the project and point the error surface property to
                    // this local file before saving the project. This will ensure that path to the FIS file is local to the project.
                    // MUST BE DONE BEFORE SAVING ERROR PROPERTIES TO THE PROJECT
                    ucErrProps.ErrSurfProperty.CloneToProject(ucName.ItemName, ucName.AbsolutePath.Directory);

                    // Create the raster then add it to the DEM survey
                    ucName.AbsolutePath.Directory.Create();
                    RasterOperators.CreateErrorRaster(DEM.Raster, ucErrProps.ErrSurfProperty.GCDErrSurfPropery, ucName.AbsolutePath, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(ucName.ItemName, ucName.AbsolutePath, DEM, chkDefault.Checked, ucErrProps.ErrSurfProperty);
                    DEM.ErrorSurfaces.Add(ErrorSurface);
                    ProjectManager.AddNewProjectItemToMap(ErrorSurface);
                }
                else
                {
                    ErrorSurface.Name = ucName.ItemName;
                }

                // Handles unsetting default on other error surface and setting it for this one
                DEM.DefaultErrorSurface = ErrorSurface;

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Error Surface Created Successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error editing single region error surface");
            }
        }
コード例 #21
0
        public void MultiMathTest()
        {
            Raster rOld = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));
            Raster rNew = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\2006FebDEM.tif")));

            using (ITempDir tmp = TempDir.Create())
            {
                Raster rSub1 = RasterOperators.Maximum(new List <Raster> {
                    rOld, rNew
                }, new FileInfo(Path.Combine(tmp.Name, "Max.tif")));
                Raster rSub2 = RasterOperators.Minimum(new List <Raster> {
                    rOld, rNew
                }, new FileInfo(Path.Combine(tmp.Name, "Min.tif")));
            }
        }
コード例 #22
0
        public void LinearExtractorEdgeCasesTest()
        {
            Raster rTemplate = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));

            Vector vNullLine = new Vector(new FileInfo(DirHelpers.GetTestVectorPath(@"Null_Line.shp")));

            // NB: Multipart lines aren't allowed so we don't need to test this
            // Vector vMPLine = new Vector(new FileInfo(DirHelpers.GetTestVectorPath(@"MultiPart_Line.shp")));

            using (ITempDir tmp = TempDir.Create())
            {
                FileInfo csvNullLine = new FileInfo(Path.Combine(tmp.Name, "Null_Line.csv"));
                RasterOperators.LinearExtractor(vNullLine, new List <Raster> {
                    rTemplate
                }, csvNullLine, 1.0m, "CATEGORY");
            }
        }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawDoD"></param>
        /// <param name="thrDoDPath"></param>
        /// <returns></returns>
        /// <remarks>Let the base class build pyramids for the thresholded raster</remarks>
        protected override Raster ThresholdRawDoD(Raster rawDoD, FileInfo thrDoDPath)
        {
            GeneratePropagatedErrorRaster(thrDoDPath.Directory);
            Raster thrDoD = null;

            // Create the prior probability raster
            m_PriorProbRaster = new FileInfo(Path.ChangeExtension(Path.Combine(thrDoDPath.DirectoryName, "priorprob"), ProjectManager.RasterExtension));
            Raster priorPRob = RasterOperators.CreatePriorProbabilityRaster(rawDoD, PropagatedErrRaster, m_PriorProbRaster, OnProgressChangeDoD);

            // Build Pyramids
            ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.ProbabilityRasters, m_PriorProbRaster);

            if (SpatialCoherence == null)
            {
                thrDoD = RasterOperators.ThresholdDoDProbability(rawDoD, PropagatedErrRaster, thrDoDPath, Threshold, OnProgressChangeDoD);
            }
            else
            {
                m_PosteriorRaster           = new FileInfo(Path.ChangeExtension(Path.Combine(thrDoDPath.DirectoryName, "postProb"), ProjectManager.RasterExtension));
                m_ConditionalRaster         = new FileInfo(Path.ChangeExtension(Path.Combine(thrDoDPath.DirectoryName, "condProb"), ProjectManager.RasterExtension));
                m_SpatialCoErosionRaster    = new FileInfo(Path.ChangeExtension(Path.Combine(thrDoDPath.DirectoryName, "nbrErosion"), ProjectManager.RasterExtension));
                m_SpatialCoDepositionRaster = new FileInfo(Path.ChangeExtension(Path.Combine(thrDoDPath.DirectoryName, "nbrDeposition"), ProjectManager.RasterExtension));

                // Count erosion and Deposition in a window around each cell
                Raster rSpatialCoErosion = RasterOperators.NeighbourCount(rawDoD, RasterOperators.GCDWindowType.Erosion, SpatialCoherence.BufferSize, m_SpatialCoErosionRaster,
                                                                          OnProgressChangeDoD);
                Raster rSpatialCoDeposition = RasterOperators.NeighbourCount(rawDoD, RasterOperators.GCDWindowType.Deposition, SpatialCoherence.BufferSize, m_SpatialCoDepositionRaster,
                                                                             OnProgressChangeDoD);

                Raster PostProb = RasterOperators.PosteriorProbability(rawDoD, priorPRob,
                                                                       rSpatialCoErosion, rSpatialCoDeposition,
                                                                       m_PosteriorRaster, m_ConditionalRaster,
                                                                       SpatialCoherence.XMin, SpatialCoherence.XMax,
                                                                       OnProgressChangeDoD);

                thrDoD = RasterOperators.ThresholdDoDProbability(rawDoD, PostProb, new FileInfo(thrDoDPath.FullName), Threshold, OnProgressChangeDoD);

                // Build Pyramids
                ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.ProbabilityRasters, m_SpatialCoErosionRaster);
                ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.ProbabilityRasters, m_SpatialCoDepositionRaster);
                ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.ProbabilityRasters, m_ConditionalRaster);
                ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.ProbabilityRasters, m_PosteriorRaster);
            }

            return(thrDoD);
        }
コード例 #24
0
        public void FISRasterTest()
        {
            Assert.Inconclusive();
            using (ITempDir tmp = TempDir.Create())
            {
                FileInfo fisFile   = new FileInfo(@"C:\code\gcd\extlib\TestData\FIS\FuzzyChinookJuvenile_03.fis");
                Raster   reference = new Raster(new FileInfo(@"C:\code\gcd\extlib\TestData\VISIT_3454\Habitat\S0000_1536\Simulations\FIS-ch_jv\PreparedInputs\Depth.tif"));

                Dictionary <string, FileInfo> inputDict = new Dictionary <string, FileInfo>()
                {
                    { "Depth", new FileInfo(@"C:\code\gcd\extlib\TestData\VISIT_3454\Habitat\S0000_1536\Simulations\FIS-ch_jv\PreparedInputs\Depth.tif") },
                    { "Velocity", new FileInfo(@"C:\code\gcd\extlib\TestData\VISIT_3454\Habitat\S0000_1536\Simulations\FIS-ch_jv\PreparedInputs\Velocity.tif") },
                    { "GrainSize_mm", new FileInfo(@"C:\code\gcd\extlib\TestData\VISIT_3454\Habitat\S0000_1536\Simulations\FIS-ch_jv\PreparedInputs\GrainSize_mm.tif") }
                };

                Raster rTemplateOutput2 = RasterOperators.FISRaster(inputDict, fisFile, reference, new FileInfo(Path.Combine(tmp.Name, "FISTest.tif")));
            }
        }
コード例 #25
0
        public void MathMaskTest()
        {
            Raster rOld = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));
            Raster rNew = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\2006FebDEM.tif")));

            Raster rOldErr = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\ErrorSurfaces\Constant01\Constant01.tif")));
            Raster rNewErr = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\ErrorSurfaces\Constant02\Constant02.tif")));

            // And now the budget seg case
            Vector vPolyMask = new Vector(new FileInfo(DirHelpers.GetTestRootPath(@"SulphurGCDMASK\Sulphur_SimpleReducedGCDMask.shp")));

            // Try this with edge case shapefiles too
            Vector vMPMG = new Vector(new FileInfo(DirHelpers.GetTestVectorPath(@"MultiPart_MultiGeometry.shp")));
            Vector vMPSG = new Vector(new FileInfo(DirHelpers.GetTestVectorPath(@"MultiPart_SingleGeometry.shp")));
            Vector vSPMG = new Vector(new FileInfo(DirHelpers.GetTestVectorPath(@"SinglePart_MultiGeometry.shp")));

            using (ITempDir tmp = TempDir.Create())
            {
                // We copy the shape files first so they get the right GCID fields
                FileInfo fiPolyMaskCopy = new FileInfo(Path.Combine(tmp.Name, "Sulphur_SimpleReducedGCDMask.shp"));
                vPolyMask.Copy(fiPolyMaskCopy);
                Vector vPolyMaskCopy = new Vector(fiPolyMaskCopy);

                Raster rSub1 = RasterOperators.SubtractWithMask(rNew, rOld, vPolyMaskCopy, new FileInfo(Path.Combine(tmp.Name, "RasterSubtractVectorMask.tif")), null, false);
                Raster rSub2 = RasterOperators.SubtractWithMask(rNew, rOld, vPolyMaskCopy, new FileInfo(Path.Combine(tmp.Name, "RasterSubtractRasterizedMask.tif")));

                FileInfo fiMPMG = new FileInfo(Path.Combine(tmp.Name, "MultiPart_MultiGeometry_Copy.shp"));
                vMPMG.Copy(fiMPMG);
                Vector vMPMGCopy = new Vector(fiMPMG);

                FileInfo fiMPSG = new FileInfo(Path.Combine(tmp.Name, "MultiPart_SingleGeometr_Copy.shp"));
                vMPSG.Copy(fiMPSG);
                Vector vMPSGCopy = new Vector(fiMPSG);

                FileInfo fiSPMG = new FileInfo(Path.Combine(tmp.Name, "SinglePart_MultiGeometry_Copy.shp"));
                vSPMG.Copy(fiSPMG);
                Vector vSPMGCopy = new Vector(fiSPMG);

                Raster rMPMG = RasterOperators.SubtractWithMask(rNew, rOld, vMPMGCopy, new FileInfo(Path.Combine(tmp.Name, "MultiPart_MultiGeometry.tif")));
                Raster rMPSG = RasterOperators.SubtractWithMask(rNew, rOld, vMPSGCopy, new FileInfo(Path.Combine(tmp.Name, "MultiPart_SingleGeometry.tif")));
                Raster rSPMG = RasterOperators.SubtractWithMask(rNew, rOld, vSPMGCopy, new FileInfo(Path.Combine(tmp.Name, "SinglePart_MultiGeometry.tif")));
                Debug.WriteLine("Done");
            }
        }
コード例 #26
0
        public void GetStatsProbalisticBudgetSegTest()
        {
            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);

            // And now the budget seg case
            Vector vPolyMask = new Vector(new FileInfo(DirHelpers.GetTestRootPath(@"SulphurGCDMASK\Sulphur_ComplexGCDMask.shp")));

            using (ITempDir tmp = TempDir.Create())
            {
                FileInfo fiPolyMaskCopy = new FileInfo(Path.Combine(tmp.Name, "Sulphur_ComplexGCDMask.shp"));
                vPolyMask.Copy(fiPolyMaskCopy);
                Vector vPolyMaskCopy = new Vector(fiPolyMaskCopy);

                Dictionary <string, DoDStats> testBudgetSeg = RasterOperators.GetStatsProbalistic(rTemp2005, rTemp2006, rTemp2005, vPolyMaskCopy, "Category", ug);
            }
        }
コード例 #27
0
        public void SetNullAbsoluteTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                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")));
                Raster rDoD      = RasterOperators.Subtract(rTemp2006, rTemp2005, new FileInfo(Path.Combine(tmp.Name, "rDoD.tif")));

                ErrorRasterProperties props02 = new ErrorRasterProperties(0.2m);
                ErrorRasterProperties props01 = new ErrorRasterProperties(0.1m);
                // 0.1 2006
                // 0.2 2005
                Raster r2005Error = RasterOperators.CreateErrorRaster(rTemp2005, props02, new FileInfo(Path.Combine(tmp.Name, "2005Dec_DEM_CONSTERR02.tif")));
                Raster r2006Error = RasterOperators.CreateErrorRaster(rTemp2006, props01, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));
                Raster propError  = RasterOperators.RootSumSquares(r2006Error, r2005Error, new FileInfo(Path.Combine(tmp.Name, "properror.tif")));

                Raster rTemplateOutput5 = RasterOperators.AbsoluteSetNull(rDoD, RasterOperators.ThresholdOps.GreaterThan, propError, new FileInfo(Path.Combine(tmp.Name, "AbsRasterGreaterThan.tif")));
            }
        }
コード例 #28
0
ファイル: RasterTests.cs プロジェクト: tarinishukla/gcd
        public void BuildPyramidsTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                // Small rasters don't need pyramids
                Raster rTempl          = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("SquareValley950-980.tif")));
                Raster rTemplateOutput = RasterOperators.ExtendedCopy(rTempl, new FileInfo(Path.Combine(tmp.Name, "SMALL_PyramidTest.tif")));

                rTemplateOutput.BuildPyramids("average");
                Assert.IsFalse(File.Exists(Path.Combine(tmp.Name, "SMALL_PyramidTest.tif.ovr")));


                // Big Rasters do need pyramids
                Raster          rBigTempl          = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
                ExtentRectangle newExtReal         = rBigTempl.Extent.Buffer(1000);
                Raster          rBigTemplateOutput = RasterOperators.ExtendedCopy(rBigTempl, new FileInfo(Path.Combine(tmp.Name, "BIG_PyramidTest.tif")), newExtReal);

                rBigTemplateOutput.BuildPyramids("average");
                Assert.IsTrue(File.Exists(Path.Combine(tmp.Name, "BIG_PyramidTest.tif.ovr")));
            }
        }
コード例 #29
0
        public void SetNullTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTempl = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const900.tif")));
                Raster rTemp2 = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("const950.tif")));

                Raster rTemplateOutput1 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.GreaterThan, 4, new FileInfo(Path.Combine(tmp.Name, "GreaterThan.tif")));
                Raster rTemplateOutput2 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.LessThan, 4, new FileInfo(Path.Combine(tmp.Name, "LessThan.tif")));
                Raster rTemplateOutput3 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.GreaterThanOrEqual, 4, new FileInfo(Path.Combine(tmp.Name, "GreaterThanOrEqual.tif")));
                Raster rTemplateOutput4 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.LessThanOrEqual, 4, new FileInfo(Path.Combine(tmp.Name, "LessThanOrEqual.tif")));

                Raster rTemplateOutput5 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.GreaterThan, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterGreaterThan.tif")));
                Raster rTemplateOutput6 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.LessThan, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterLessThan.tif")));
                Raster rTemplateOutput7 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.GreaterThanOrEqual, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterGreaterThanOrEqual.tif")));
                Raster rTemplateOutput8 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.LessThanOrEqual, rTemp2, new FileInfo(Path.Combine(tmp.Name, "RasterLessThanOrEqual.tif")));


                Raster rTemplateOutput9 = RasterOperators.SetNull(rTempl, RasterOperators.ThresholdOps.GreaterThan, 4, RasterOperators.ThresholdOps.LessThanOrEqual, 10, new FileInfo(Path.Combine(tmp.Name, "DoubleOp.tif")));
            }
        }
コード例 #30
0
        public void MultiMathErrorTest()
        {
            Raster rOld = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\2005DecDEM.tif")));
            Raster rNew = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\2006FebDEM.tif")));

            Raster rOldErr = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2005DecDEM\ErrorSurfaces\Constant01\Constant01.tif")));
            Raster rNewErr = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"VerificationProject\inputs\2006FebDEM\ErrorSurfaces\Constant02\Constant02.tif")));

            using (ITempDir tmp = TempDir.Create())
            {
                Raster rSub2 = RasterOperators.MinimumErr(new List <Raster> {
                    rOld, rNew
                }, new List <Raster> {
                    rOldErr, rNewErr
                }, new FileInfo(Path.Combine(tmp.Name, "MinErr.tif")));
                Raster rSub1 = RasterOperators.MaximumErr(new List <Raster> {
                    rOld, rNew
                }, new List <Raster> {
                    rOldErr, rNewErr
                }, new FileInfo(Path.Combine(tmp.Name, "MaxErr.tif")));
            }
        }