Beispiel #1
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            // Validates the input and output data
            if (_inputParam[0].Value is not IRaster raster || _inputParam[1].Value is not IFeatureSet polygon || _outputParam[0].Value is not IRaster output)
            {
                return(false);
            }

            ClipRaster.ClipRasterWithPolygon(polygon.Features[0], raster, output.Filename, cancelProgressHandler);
            return(true);
        }
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IRaster     raster  = _inputParam[0].Value as IRaster;
            IFeatureSet polygon = _inputParam[1].Value as IFeatureSet;
            IRaster     output  = _outputParam[0].Value as IRaster;

            // Validates the input and output data
            if (raster == null || polygon == null || output == null)
            {
                return(false);
            }

            ClipRaster.ClipRasterWithPolygon(polygon.Features[0], raster, output.Filename, cancelProgressHandler);
            return(true);
        }
Beispiel #3
0
        public void ClipRasterWithPolygonTest()
        {
            var shapeFilePath  = Path.Combine("Data", "elbe_watershed1.shp");
            var rasterFilePath = Path.Combine("Data", "kriging.bgd");
            var resultFilePath = Path.Combine("Data", "clipResult.bgd");

            var lClipPolygon = Shapefile.OpenFile(shapeFilePath);
            var lGridToClip  = Raster.OpenFile(rasterFilePath, false);

            var lGridAfterClip = new Raster {
                Filename = resultFilePath
            };

            ClipRaster.ClipRasterWithPolygon(lClipPolygon.Features[0], lGridToClip, lGridAfterClip.Filename);
            var ras2 = Raster.Open(lGridAfterClip.Filename);

            Assert.AreEqual(lGridToClip.NoDataValue, ras2.NoDataValue);
        }