public void CanCreateMultiPartPolygons(string file)
        {
            var target = new RasterToPolygon();
            var p = new GdalRasterProvider();
            var raster = p.Open(file);
            var outShape = new PolygonShapefile {Filename = FileTools.GetTempFileName(".shp")};
            target.Execute(raster, outShape, new MockProgressHandler());
            FileTools.DeleteShapeFile(outShape.Filename);

            var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon);
            Assert.That(mpCount > 0);
        }
        public void CanCreateMultiPartPolygons(string path)
        {
            var target = new RasterToPolygon();
            var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
            
            var p = new GdalRasterProvider();
            var raster = p.Open(file);
            var outShape = new PolygonShapefile {Filename = Path.ChangeExtension(file, ".shp")};
            target.Execute(raster, outShape, new MockProgressHandler());

            var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon);
            Assert.That(mpCount > 0);
        }
        public void NoMultiPartPolygonsWithConnectionGrid(string rasterFile, string flowDirectionGridFile)
        {
            var p = new GdalRasterProvider();
            var raster = p.Open(rasterFile);
            var flowDirectionGrid = p.Open(flowDirectionGridFile);

            var target = new RasterToPolygon();
            var outShape = new PolygonShapefile { Filename = FileTools.GetTempFileName(".shp") };
            target.Execute(raster, flowDirectionGrid, outShape, new MockProgressHandler());
            FileTools.DeleteShapeFile(outShape.Filename);

            var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon);
            Assert.That(mpCount == 0);
        }
        public void NoMultiPartPolygonsWithConnectionGrid(string rasterFile, string flowDirectionGridFile)
        {
            rasterFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rasterFile);
            flowDirectionGridFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, flowDirectionGridFile);

            var p = new GdalRasterProvider();
            var raster = p.Open(rasterFile);
            var flowDirectionGrid = p.Open(flowDirectionGridFile);

            var target = new RasterToPolygon();
            var outShape = new PolygonShapefile { Filename = Path.ChangeExtension(rasterFile, ".shp") };
            target.Execute(raster, flowDirectionGrid, outShape, new MockProgressHandler());

            var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon);
            Assert.That(mpCount == 0);
        }
示例#5
0
        public static bool LoadDataSourcePlugins()
        {
            try
            {
                if (atcDataManager.DataSources is null)
                {
                    atcDataManager.Clear();
                }
                if (atcDataManager.DataPlugins.Count > 0)
                {
                    return(true);
                }
                var att = new atcDataAttributes();
                atcTimeseriesStatistics.atcTimeseriesStatistics.InitializeShared();
                //var datasources = atcDataManager.GetPlugins(typeof(atcDataSource));
                atcTimeseriesNdayHighLow.atcTimeseriesNdayHighLow.InitializeShared();
                var script = new atcTimeseriesScript.atcTimeseriesScriptPlugin();
                atcDataManager.DataPlugins.Add(script);
                var lRDB = new atcTimeseriesRDB.atcTimeseriesRDB();
                atcDataManager.DataPlugins.Add(lRDB);
                var listPlugin = new atcList.atcListPlugin();
                atcDataManager.DataPlugins.Add(listPlugin);
                var graphPlugin = new atcGraph.atcGraphPlugin();
                atcDataManager.DataPlugins.Add(graphPlugin);
                TSMath = new atcTimeseriesMath.atcTimeseriesMath();
                var saPlugin = new atcSeasonalAttributes.atcSeasonalAttributesPlugin();
                atcDataManager.DataPlugins.Add(saPlugin);
                var sPlugin = new atcSeasons.atcSeasonPlugin();
                atcDataManager.DataPlugins.Add(sPlugin);
                var bfPlugin = new atcTimeseriesBaseflow.atcTimeseriesBaseflow();
                atcDataManager.DataPlugins.Add(bfPlugin);

                var gdalRasterHandle = new DotSpatial.Data.Rasters.GdalExtension.GdalRasterProvider();
                var gdalImageHandle  = new DotSpatial.Data.Rasters.GdalExtension.GdalImageProvider();
                DotSpatial.Data.DataManager.DefaultDataManager.PreferredProviders.Add("GdalImageProvider", gdalImageHandle);
                var gdalOgrHandle = new DotSpatial.Data.Rasters.GdalExtension.OgrDataProvider();
                DotSpatial.Data.DataManager.DefaultDataManager.PreferredProviders.Add("OgrDataProvider", gdalOgrHandle);
                //DotSpatial.Symbology.RasterLayer.MaxCellsInMemory = 80 * 60;

                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Print(e.InnerException.Message);
                return(false);
            }
        }
示例#6
0
        public void SaveAsTest()
        {
            const string GridDataFolder = @"Data\Grids\";
            var p = new GdalRasterProvider();
            var sourceGrid = p.Open(GridDataFolder + @"elev_cm_ESRI\elev_cm_clip2\hdr.adf");
            var sourceGridMaximum = sourceGrid.Maximum;

            const string savedGridName = GridDataFolder + @"elev_cm.tif";
            sourceGrid.SaveAs(savedGridName);

            Assert.AreEqual(sourceGrid.Maximum, sourceGridMaximum, 0.0001);

            var savedSourceGrid = Raster.Open(savedGridName);

            Assert.AreEqual(sourceGridMaximum, savedSourceGrid.Maximum, 0.0001);

            sourceGrid.Close();
            savedSourceGrid.Close();
            File.Delete(savedGridName);
        }
示例#7
0
        public void SaveAsTest()
        {
            var GridDataFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data\Grids\");
            var p = new GdalRasterProvider();
            var sourceGrid = p.Open(GridDataFolder + @"elev_cm_ESRI\elev_cm_clip2\hdr.adf");
            var sourceGridMaximum = sourceGrid.Maximum;

            var savedGridName = GridDataFolder + @"elev_cm.tif";
            sourceGrid.SaveAs(savedGridName);

            Assert.AreEqual(sourceGrid.Maximum, sourceGridMaximum, 0.0001);

            var savedSourceGrid = Raster.Open(savedGridName);

            Assert.AreEqual(sourceGridMaximum, savedSourceGrid.Maximum, 0.0001);

            sourceGrid.Close();
            savedSourceGrid.Close();
            File.Delete(savedGridName);
        }
示例#8
0
        public void SaveAsTest()
        {
            var p = new GdalRasterProvider();
            var sourceGrid = p.Open(FileTools.PathToTestFile( @"Rasters\elev_cm_ESRI\elev_cm_clip2\hdr.adf"));
            var sourceGridMaximum = sourceGrid.Maximum;

            var savedGridName = FileTools.GetTempFileName(".tif");
            try
            {
                sourceGrid.SaveAs(savedGridName);
                Assert.AreEqual(sourceGrid.Maximum, sourceGridMaximum, 0.0001);

                var savedSourceGrid = Raster.Open(savedGridName);
                Assert.AreEqual(sourceGridMaximum, savedSourceGrid.Maximum, 0.0001);

                sourceGrid.Close();
                savedSourceGrid.Close();
            }
            finally
            {
                File.Delete(savedGridName);
            }
        }
示例#9
0
        public void CanOpenRasterAfterClose()
        {
            var rasterFileName = FileTools.GetTempFileName(".tif");
            var p = new GdalRasterProvider();
            var raster = p.Create(rasterFileName, null, 20, 20, 1, typeof(float), new[] { "" });
            raster.Close();

            try
            {
                using (var openTif = File.Open(rasterFileName, FileMode.Open))
                    Assert.IsNotNull(openTif);
            }
            finally
            {
                File.Delete(rasterFileName);
            }
        }