当前位置: 首页>>代码示例>>C#>>正文


C# IProgressHandler.Progress方法代码示例

本文整理汇总了C#中IProgressHandler.Progress方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressHandler.Progress方法的具体用法?C# IProgressHandler.Progress怎么用?C# IProgressHandler.Progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgressHandler的用法示例。


在下文中一共展示了IProgressHandler.Progress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyWatershedSlopeAttribute

        /// <summary>
        /// Hydrology function used to add to the subbasin shapefile average slope attribute
        /// </summary>
        /// <param name="subBasinShapePath"></param>
        /// <param name="slopeGridPath"></param>
        /// <param name="elevUnits"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static bool ApplyWatershedSlopeAttribute(string subBasinShapePath, string slopeGridPath, ElevationUnits elevUnits, IProgressHandler callback)
        {
            // CWG 23/1/2011 changed to GeoTiff for Taudem V5
            var tmpClipPath = Path.Combine(
                Path.GetDirectoryName(slopeGridPath), Path.GetFileNameWithoutExtension(slopeGridPath) + "_clip.tif");

            //DataManagement.DeleteGrid(tmpClipPath);

            if (callback != null)
            {
                callback.Progress("Status", 0, "Calculating WS Slope Parameters");
            }

            var shedShape = FeatureSet.Open(subBasinShapePath);

            var slopeGrid = Raster.Open(slopeGridPath);
            var slopeProj = slopeGrid.Projection;
            slopeGrid.Close();

            var countSlope = new int[shedShape.NumRows()];
            var sumSlope = new double[shedShape.NumRows()];
            var avgSlope = new double[shedShape.NumRows()];

            var oldperc = 0;
            for (var sindx = 0; sindx < shedShape.NumRows(); sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows() - 1)) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
                        {
                            callback.Progress("Status", newperc, "Calculating WS Slope Parameters");
                        }

                        oldperc = newperc;
                    }
                }
                var tmpPoly = shedShape.get_Shape(sindx);

                if (ClipRaster.ClipRasterWithPolygon(slopeGridPath, tmpPoly, tmpClipPath) != null)
                {
                    continue;
                }

                var tmpClipGrid = Raster.Open(tmpClipPath);

                var numberRows = tmpClipGrid.NumRows;
                var numberCols = tmpClipGrid.NumColumns;
                var nodataVal = tmpClipGrid.NoDataValue;
                countSlope[sindx] = 0;
                sumSlope[sindx] = 0;
                avgSlope[sindx] = 0;
                int row;
                for (row = 0; row < numberRows; row += 2)
                {
                    int col;
                    for (col = 0; col < numberCols; col += 2)
                    {
                        var currVal = double.Parse(tmpClipGrid.Rows[col][row].ToString());
                        if (currVal == nodataVal)
                        {
                            continue;
                        }

                        countSlope[sindx] = countSlope[sindx] + 1;
                        sumSlope[sindx] = sumSlope[sindx] + currVal;
                    }
                }

                tmpClipGrid.Close();

                //DataManagement.DeleteGrid(tmpClipPath);
            }

            if (callback != null)
            {
                callback.Progress("Status", 0, "Calculating WS Slope Parameters");
            }

            var slopeFieldNum = AddField(shedShape, "AveSlope", typeof(double));

            oldperc = 0;
            for (var sindx = 0; sindx < shedShape.NumRows(); sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows())) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例2: ApplyWatershedLinkAttributes

        /// <summary>
        /// Hydrology function to apply the watershed link attributes copied or interpretted from the stream network
        /// </summary>
        /// <param name="subBasinShapePath"></param>
        /// <param name="streamNetworkShapePath"></param>
        /// <param name="callback"></param>
        /// <returns>0 on success</returns>
        public static int ApplyWatershedLinkAttributes(
            string subBasinShapePath, string streamNetworkShapePath, IProgressHandler callback)
        {
            int shedIndex;

            if (callback != null) callback.Progress("Status", 0, "Assigning WS Link");

            //Stream fields
            const int IDField = 0;
            const int DsidField = 1;
            const int Us1IDField = 2;
            const int Us2IDField = 3;
            const int DsNodeIDField = 4;
            const int StreamLenID = 6;

            IFeatureSet streamShape = FeatureSet.Open(streamNetworkShapePath);
            if (streamShape == null)
            {
                throw new ApplicationException(String.Format("Error in opening {0}", streamNetworkShapePath));
            }
            int streamShapeNumShapes = streamShape.NumRows();

            IFeatureSet shedShape = FeatureSet.Open(subBasinShapePath);
            if (shedShape == null)
            {
                throw new ApplicationException(String.Format("Error in opening {0}", subBasinShapePath));
            }
            int shedShapeNumShapes = shedShape.NumRows();

            const int WShedIDField = 0;
            int streamLinkFieldNum = AddField(shedShape, "StreamLinkNo", typeof(int));
            int streamLenFieldNum = AddField(shedShape, "StreamLen", typeof(int));
            int dsnodeidFieldNum = AddField(shedShape, "DSNodeID", typeof(int));
            int dslinkFieldNum = AddField(shedShape, "DSWSID", typeof(int));
            int us1LinkFieldNum = AddField(shedShape, "US1WSID", typeof(int));
            int us2LinkFieldNum = AddField(shedShape, "US2WSID", typeof(int));

            int oldperc = 0;
            int uS1WSID;
            int dSWSID;
            int us2Wsid;

            for (shedIndex = 0; shedIndex < shedShapeNumShapes; shedIndex++)
            {
                if (callback != null && shedShapeNumShapes > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(shedIndex) / Convert.ToDouble(shedShapeNumShapes)) * 100);
                    if (newperc > oldperc)
                    {
                        callback.Progress("Status", newperc, "Assigning WS Link");
                        oldperc = newperc;
                    }
                }

                // Change watershed ID from zero-based to one-based to match change to stream ID in ApplyStreamAttributes
                int WatershedID = Convert.ToInt32(shedShape.get_CellValue(WShedIDField, shedIndex)) + 1; 
                shedShape.EditCellValue(WShedIDField, shedIndex, WatershedID);
                for (int streamIndex = 0; streamIndex < streamShapeNumShapes; streamIndex++)
                {   //Stream IDs have already been incremented to start at 1 in ApplyStreamAttributes, so match with incremented Watershed ID
                    if (Convert.ToInt32(streamShape.get_CellValue(IDField, streamIndex)) == WatershedID)
                    {
                        shedShape.EditCellValue(dsnodeidFieldNum, shedIndex, streamShape.get_CellValue(DsNodeIDField, streamIndex));
                        shedShape.EditCellValue(streamLinkFieldNum, shedIndex, streamShape.get_CellValue(IDField, streamIndex));
                        shedShape.EditCellValue(streamLenFieldNum, shedIndex, streamShape.get_CellValue(StreamLenID, streamIndex));
                        int currDsStreamLink = Convert.ToInt32(streamShape.get_CellValue(DsidField, streamIndex));
                        int currUs1StreamLink = Convert.ToInt32(streamShape.get_CellValue(Us1IDField, streamIndex));
                        int currUs2StreamLink = Convert.ToInt32(streamShape.get_CellValue(Us2IDField, streamIndex));

                        if (currDsStreamLink == -1)
                        {
                            dSWSID = -1;
                        }
                        else
                        {
                            dSWSID = currDsStreamLink; // GetWshedFromStreamLink(currDsStreamLink, streamShape, shedShape);
                        }

                        if (currUs1StreamLink <= 0)
                        {
                            uS1WSID = -1;
                        }
                        else
                        {
                            uS1WSID = currUs1StreamLink; // GetWshedFromStreamLink(currUs1StreamLink, streamShape, shedShape);
                        }

                        if (currUs2StreamLink <= 0)
                        {
                            us2Wsid = -1;
                        }
                        else
                        {
                            us2Wsid = currUs2StreamLink; // GetWshedFromStreamLink(currUs2StreamLink, streamShape, shedShape);
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例3: ApplyWatershedAreaAttributes

        /// <summary>
        /// A function to apply area attributes to a watershed polygon shapefile
        /// </summary>
        /// <param name="subBasinShapePath">Subbasin shapefile</param>
        /// <param name="callback">Callback object</param>
        /// <returns>True on success</returns>
        public static bool ApplyWatershedAreaAttributes(string subBasinShapePath, IProgressHandler callback)
        {
            if (callback != null)
            {
                callback.Progress("Status", 0, "Calculating WS Area Parameters");
            }

            var shedShape = FeatureSet.Open(subBasinShapePath);

            var areaMFieldNum = AddField(shedShape, "Area_M", typeof(double));
            var areaAcreFieldNum = AddField(shedShape, "Area_Acre", typeof(double));
            var areaMileFieldNum = AddField(shedShape, "Area_SqMi", typeof(double));

            double areaM = 0;
            var oldperc = 0;

            for (var sindx = 0; sindx < shedShape.NumRows(); sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows())) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
                        {
                            callback.Progress("Status", newperc, "Calculating WS Area Parameters");
                        }

                        oldperc = newperc;
                    }
                }
                var tmpShp = shedShape.get_Shape(sindx);

                var tmpArea = Utils.AreaOfPart(tmpShp, 0);
                if (shedShape.Projection != null || String.IsNullOrWhiteSpace(shedShape.Projection.ToString()))
                {
                    if (shedShape.Projection.Unit.Name == "Meter")
                    {
                        areaM = tmpArea;
                    }
                    else if (shedShape.Projection.Unit.Name == "Foot")
                    {
                        areaM = tmpArea * 0.09290304;
                    }
                }
                else
                {
                    areaM = tmpArea;
                }

                var areaAcre = areaM * 0.000247105;
                var areaSqMi = areaAcre * 0.0015625;
                shedShape.EditCellValue(areaMFieldNum, sindx, areaM);
                shedShape.EditCellValue(areaAcreFieldNum, sindx, areaAcre);
                shedShape.EditCellValue(areaMileFieldNum, sindx, areaSqMi);
            }

            shedShape.Save();
            shedShape.Close();

            if (callback != null)
            {
                callback.Progress(string.Empty, 0, string.Empty);
            }

            return true;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:73,代码来源:Hydrology.cs

示例4: ApplyWatershedElevationAttribute

        /// <summary>
        /// Hydrology function used to add to the subbasin shapefile average elevation attribute
        /// </summary>
        /// <param name="SubBasinShapePath"></param>
        /// <param name="ElevGridPath"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static bool ApplyWatershedElevationAttribute(string SubBasinShapePath, string ElevGridPath, IProgressHandler callback)
        {
            int sindx;
            int col, row;
            int[] countElev;
            double[] sumElev;
            double[] avgElev;

            int newperc = 0, oldperc = 0;
            IFeature tmpPoly;
            // CWG 23/1/2011 changed to GeoTiff for Taudem V5
            string tmpClipPath = Path.GetDirectoryName(ElevGridPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(ElevGridPath) + "_clip.tif";

            double currVal, nodataVal;
            int nr, nc;
            if (callback != null) callback.Progress("Status", 0, "Calculating WS Elevation Parameters");
            var shedShape = FeatureSet.Open(SubBasinShapePath);
            var elevGrid = Raster.Open(ElevGridPath);

            countElev = new int[shedShape.NumRows()];
            sumElev = new double[shedShape.NumRows()];
            avgElev = new double[shedShape.NumRows()];

            DataManagement.DeleteGrid(tmpClipPath);
            for (sindx = 0; sindx <= shedShape.NumRows() - 1; sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows() - 1)) * 100);
                    if ((newperc > oldperc))
                    {
                        if (callback != null) callback.Progress("Status", newperc, "Calculating WS Elevation Parameters");
                        oldperc = newperc;
                    }
                }

                tmpPoly = shedShape.get_Shape(sindx);
                IRaster tmpClipGrid = ClipRaster.ClipRasterWithPolygon(ElevGridPath, tmpPoly, tmpClipPath);
                if (tmpClipGrid != null)
                {
                    nr = tmpClipGrid.NumRows;
                    nc = tmpClipGrid.NumColumns;
                    nodataVal = tmpClipGrid.NoDataValue;
                    countElev[sindx] = 0;
                    sumElev[sindx] = 0;
                    avgElev[sindx] = 0;
                    for (row = 0; row <= nr - 1; row += 2)
                    {
                        for (col = 0; col <= nc - 1; col += 2)
                        {
                            currVal = tmpClipGrid.Value[row, col];
                            if (currVal != nodataVal)
                            {
                                countElev[sindx] = countElev[sindx] + 1;
                                sumElev[sindx] = sumElev[sindx] + currVal;
                            }
                        }
                    }
                    tmpClipGrid.Close();
                    DataManagement.DeleteGrid(tmpClipPath);
                }
            }
            if (callback != null) callback.Progress("Status", 0, "Calculating WS Elevation Parameters");

            int slopeFieldNum = AddField(shedShape, "AveElev", typeof(double));

            string slopeProj = elevGrid.Projection.ToString();
            newperc = 0;
            oldperc = 0;
            for (sindx = 0; sindx <= shedShape.NumRows() - 1; sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows())) * 100);
                    if ((newperc > oldperc))
                    {
                        if (callback != null) callback.Progress("Status", newperc, "Calculating WS Elevation Parameters");
                        oldperc = newperc;
                    }
                }
                if (countElev[sindx] > 0)
                {
                    avgElev[sindx] = (sumElev[sindx] / countElev[sindx]);

                    shedShape.EditCellValue(slopeFieldNum, sindx, avgElev[sindx]);
                }
            }

            shedShape.Save();
            shedShape.Close();
            elevGrid.Close();

            if (callback != null) callback.Progress(String.Empty, 0, String.Empty);
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例5: ApplyWatershedLinkAttributes

        /// <summary>
        /// Hydrology function to apply the watershed link attributes copied or interpretted from the stream network
        /// </summary>
        /// <param name="subBasinShapePath"></param>
        /// <param name="streamNetworkShapePath"></param>
        /// <param name="callback"></param>
        /// <returns>0 on success</returns>
        public static int ApplyWatershedLinkAttributes(
            string subBasinShapePath, string streamNetworkShapePath, IProgressHandler callback)
        {
            int sindx;

            if (callback != null)
            {
                callback.Progress("Status", 0, "Assigning WS Link");
            }

            //const int IDField = 0;
            const int DsidField = 1;
            const int Us1IDField = 2;
            const int Us2IDField = 3;
            //const int DsNodeIDField = 4;
            //const int StreamLenID = 6;
            //const int WaterShedIDField = 13;

            var shedShape = FeatureSet.Open(subBasinShapePath);

            var streamShape = FeatureSet.Open(streamNetworkShapePath);

            var streamLinkFieldNum = AddField(shedShape, "StreamLinkNo", typeof(int));
            var streamLenFieldNum = AddField(shedShape, "StreamLen", typeof(int));
            var dsnodeidFieldNum = AddField(shedShape, "DSNodeID", typeof(int));
            var dslinkFieldNum = AddField(shedShape, "DSWSID", typeof(int));
            var us1LinkFieldNum = AddField(shedShape, "US1WSID", typeof(int));
            var us2LinkFieldNum = AddField(shedShape, "US2WSID", typeof(int));

            var oldperc = 0;
            int uS1WSID;
            int dSWSID;
            int us2Wsid;

            for (sindx = 0; sindx < shedShape.NumRows(); sindx++)
            {
                if (shedShape.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shedShape.NumRows())) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
                        {
                            callback.Progress("Status", newperc, "Assigning WS Link");
                        }

                        oldperc = newperc;
                    }
                }

                var currStreamIndx = -1;
                //int streamindx;
                //for (streamindx = 0; streamindx < streamShape.NumRows(); streamindx++)
                //{
                //    if ((int)streamShape.get_CellValue(WaterShedIDField, streamindx)
                //        != (int)shedShape.get_CellValue(IDField, sindx))
                //    {
                //        continue;
                //    }

                //    currStreamIndx = streamindx;

                //    shedShape.EditCellValue(dsnodeidFieldNum, sindx, streamShape.get_CellValue(DsNodeIDField, streamindx));
                //    shedShape.EditCellValue(streamLinkFieldNum, sindx, streamShape.get_CellValue(IDField, streamindx));
                //    shedShape.EditCellValue(streamLenFieldNum, sindx, streamShape.get_CellValue(StreamLenID, streamindx));
                //    break;
                //}

                if (currStreamIndx <= -1)
                {
                    continue;
                }

                var currDsStreamLink = (int)streamShape.get_CellValue(DsidField, currStreamIndx);
                var currUs1StreamLink = (int)streamShape.get_CellValue(Us1IDField, currStreamIndx);
                var currUs2StreamLink = (int)streamShape.get_CellValue(Us2IDField, currStreamIndx);

                if (currDsStreamLink == -1)
                {
                    dSWSID = -1;
                }
                else
                {
                    dSWSID = GetWshedFromStreamLink(currDsStreamLink, streamShape, shedShape);
                }

                if (currUs1StreamLink == 0 | currUs1StreamLink == -1)
                {
                    uS1WSID = -1;
                }
                else
                {
                    uS1WSID = GetWshedFromStreamLink(currUs1StreamLink, streamShape, shedShape);
//.........这里部分代码省略.........
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:101,代码来源:Hydrology.cs

示例6: ApplyJoinBasinStreamAttributes

        /// <summary>
        /// A function that gets the mean width, mean height, length, and slope of the primary stream in the basin
        /// </summary>
        /// <param name="networkShapePath">The path to the streams network shapefile</param>
        /// <param name="basinShapePath">The path to the unjoined watershed shapefile</param>
        /// <param name="joinBasinShapePath">The path to the Joined Basins shapefile</param>
        /// <param name="callback">A mapwindow callback</param>
        /// <returns></returns>
        public static bool ApplyJoinBasinStreamAttributes(string networkShapePath, string basinShapePath, string joinBasinShapePath, IProgressHandler callback)
        {
            if (callback != null)
            {
                callback.Progress("Status", 0, "Calculating Merge Shed Area Attributes");
            }

            var shedShapefile = FeatureSet.Open(basinShapePath);

            var streamLinkFieldNum = -1;
            for (var i = 0; i < shedShapefile.DataTable.Columns.Count; i++)
            {
                if (shedShapefile.DataTable.Columns[i].ColumnName == "StreamLink")
                {
                    streamLinkFieldNum = i;
                    break;
                }
            }

            var netShapefile = FeatureSet.Open(networkShapePath);

            var streamIdfn = -1;
            var streamLengthFn = -1;
            var streamSlopeFn = -1;
            var streamMeanWidthFn = -1;
            var streamMeanDepthFn = -1;
            for (var i = 0; i < netShapefile.DataTable.Columns.Count; i++)
            {
                switch (netShapefile.DataTable.Columns[i].ColumnName)
                {
                    case "LINKNO":
                        streamIdfn = i;
                        break;
                    case "Length":
                        streamLengthFn = i;
                        break;
                    case "Slope":
                        streamSlopeFn = i;
                        break;
                    case "MeanWidth":
                        streamMeanWidthFn = i;
                        break;
                    case "MeanDepth":
                        streamMeanDepthFn = i;
                        break;
                }
            }

            var mergeshedShapefile = FeatureSet.Open(joinBasinShapePath);

            var linkIDsFieldNum = -1;
            for (var i = 0; i < mergeshedShapefile.DataTable.Columns.Count; i++)
            {
                if (mergeshedShapefile.DataTable.Columns[i].ColumnName == "LinkIDs")
                {
                    linkIDsFieldNum = i;
                    break;
                }
            }

            //mergeshedShapefile.StartEditingShapes(true, null);
            var streamwidthfieldnum = AddField(mergeshedShapefile, "CH_W2", typeof(double));
            var streamdepthfieldnum = AddField(mergeshedShapefile, "CH_D", typeof(double));
            var streamlengthfieldnum = AddField(mergeshedShapefile, "CH_L", typeof(double));
            var streamslopefieldnum = AddField(mergeshedShapefile, "CH_S", typeof(double));

            var oldperc = 0;
            for (var i = 0; i < mergeshedShapefile.NumRows(); i++)
            {
                if (mergeshedShapefile.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(i) / Convert.ToDouble(mergeshedShapefile.NumRows())) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
                        {
                            callback.Progress("Status", newperc, "Calculating Merge Shed Area Attributes");
                        }

                        oldperc = newperc;
                    }
                }

                var currLinkIDs = mergeshedShapefile.get_CellValue(linkIDsFieldNum, i).ToString();
                var links = currLinkIDs.Split(',');
                var shedID = int.Parse(links[0]);
                var shedIndex = GetBasinIndexByID(shedShapefile, shedID);
                var streamLink = shedShapefile.get_CellValue(streamLinkFieldNum, shedIndex).ToString();

                for (var j = 0; j < netShapefile.NumRows(); j++)
                {
                    if (netShapefile.get_CellValue(streamIdfn, j).ToString() != streamLink)
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例7: ApplyStreamAttributes


//.........这里部分代码省略.........
        //                " -om " + MovedOutletsPath +
        //                " -md " + Thresh.ToString();
        //            result = RunTaudem("MoveOutletsToStreams.exe", pars, numProcesses, showTaudemOutput);
        //            if (result != 0)
        //            {
        //                MessageBox.Show("TauDEM Error " + result, "TauDEM Error " + result, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.DialogResult.OK);
        //                return result;
        //            }

        //            DataManagement.TryCopy(System.IO.Path.ChangeExtension(OutletsPath, ".prj"),
        //                                   System.IO.Path.ChangeExtension(MovedOutletsPath, ".prj"));
        //            if (callback != null) callback.Progress("Status", 0, String.Empty);
        //           Trace.WriteLine("Finished Move Outlets to Streams");
        //            return result;
        //        }
        //        #endregion

        //        #region "Apply Stream Attributes"

        /// <summary>
        ///   Hydrology function used to add to the stream shapefile attributes
        /// </summary>
        /// <param name = "streamNetworkShapePath"></param>
        /// <param name = "demPath"></param>
        /// <param name = "subBasinShapePath"></param>
        /// <param name = "elevUnits"></param>
        /// <param name = "callback"></param>
        /// <returns></returns>
        public static bool ApplyStreamAttributes(
            string streamNetworkShapePath,
            string demPath,
            string subBasinShapePath,
            ElevationUnits elevUnits,
            IProgressHandler callback)
        {
            int sindx;
            int oldperc = 0;
            const int IDField = 0;
            const int DsField = 1;
            const int Us1Field = 2;
            const int Us2Field = 3;
            const int DsAreaField = 8;
            const int SlopeField = 10;
            const int UsAreaField = 12;

            if (callback != null)
            {
                callback.Progress("Status", 0, "Calculating Stream Parameters");
            }

            if (!File.Exists(streamNetworkShapePath))
            {
                MessageBox.Show(string.Format(@"The file {0} does not exists! ", streamNetworkShapePath));
                return false;
            }

            IFeatureSet streamShape = FeatureSet.Open(streamNetworkShapePath);
            if (streamShape == null)
            {
                throw new ApplicationException(String.Format("Error in opening {0}", streamNetworkShapePath));
            }
            int streamShapeNumShapes = streamShape.NumRows();

            // Add some fields:
            int lowFieldNum = AddField(streamShape, "ElevLow", typeof(double));
            int highFieldNum = AddField(streamShape, "Elevhigh", typeof(double));
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:67,代码来源:Hydrology.cs

示例8: BuildJoinedBasins

        /// <summary>
        /// Overload of BuildJoinedBasins that takes an outlets shape path used for Inlets resolution. If no outlets/inlets path given, it will treat all points as outlets
        /// </summary>
        // 2/11/09 rewritten by Chris George to dramatically improve speed:
        //  (a) use utils.ClipPolygon instead of SpatialOperations.MergeShapes
        //  (b) create a binary tree modeling the drainage pattern of the subbasins
        //  (b) merge "upstream-first" using the drainage tree so that each merge combines abutting polygons
        public static bool BuildJoinedBasins(string subBasinShapePath, string outletsShapePath, string joinBasinShapeResultPath, IProgressHandler callback)
        {
            var shapeIdxList = new ArrayList();
            BinTree drainage;

            IFeatureSet outlets = null;
            if (outletsShapePath != string.Empty)
            {
                outlets = FeatureSet.Open(outletsShapePath);
            }

            var shed = FeatureSet.Open(subBasinShapePath);

            var dsNodeFieldNum = -1;
            var dsShedFieldNum = -1;
            var us1FieldNum = -1;
            var us2FieldNum = -1;

            for (var i = 0; i < shed.DataTable.Columns.Count; i++)
            {
                switch (shed.DataTable.Columns[i].ColumnName.ToUpper())
                {
                    case "DSNODEID":
                        dsNodeFieldNum = i;
                        break;
                    case "DSWSID":
                        dsShedFieldNum = i;
                        break;
                    case "US1WSID":
                        us1FieldNum = i;
                        break;
                    case "US2WSID":
                        us2FieldNum = i;
                        break;
                }
            }

            //DataManagement.DeleteShapefile(joinBasinShapeResultPath);

            var newShed = new FeatureSet();
            newShed.FeatureType = FeatureType.Polygon;
            newShed.Filename = joinBasinShapeResultPath;

            var idfieldnum = AddField(newShed, "MWShapeID", typeof(int));
            var linkfieldnum = AddField(newShed, "LinkIDs", typeof(string));
            var outletfieldnum = AddField(newShed, "OutletID", typeof(int));
            var dswsfieldnum = AddField(newShed, "DSWSID", typeof(int));
            var uswsfieldnum1 = AddField(newShed, "USWSID1", typeof(int));
            var uswsfieldnum2 = AddField(newShed, "USWSID2", typeof(int));
            var reservoirfieldnum = AddField(newShed, "Reservoir", typeof(int));

            var oldperc = 0;
            for (var sindx = 0; sindx < shed.NumRows(); sindx++)
            {
                if (shed.NumRows() > 1)
                {
                    var newperc = Convert.ToInt32((Convert.ToDouble(sindx) / Convert.ToDouble(shed.NumRows())) * 100);
                    if (newperc > oldperc)
                    {
                        if (callback != null)
                        {
                            callback.Progress("Status", newperc, "Merging Watersheds to Outlets/Inlets");
                        }

                        oldperc = newperc;
                    }
                }

                DSNode dsNodeType = DSNode.Outlet;
                var dsNodeVal = int.Parse(shed.get_CellValue(dsNodeFieldNum, sindx).ToString());

                if (dsNodeVal > -1)
                {
                    // an outlet, inlet, reservoir or point source
                    if (outletsShapePath == string.Empty)
                    {
                        // assume this is an outlet
                        drainage = getDrainageFromSubbasin(shed, outlets, false, true, sindx, dsNodeFieldNum, us1FieldNum, us2FieldNum);
                    }
                    else
                    {
                        dsNodeType = getDSNodeType(outlets, dsNodeVal);
                        if ((dsNodeType == DSNode.Outlet) || (dsNodeType == DSNode.Reservoir))
                        {
                            if (isUpstreamOfInlet(shed, outlets, sindx))
                            {
                                drainage = null;
                            }
                            else
                            {
                                drainage = getDrainageFromSubbasin(shed, outlets, true, true, sindx, dsNodeFieldNum, us1FieldNum, us2FieldNum);
                            }
                        }
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例9: RunStreamOrderGridRaster

        /// <summary>
        /// Call StreamNet.exe
        /// </summary>
        /// <param name="demGridPath">Input file</param>
        /// <param name="pitFillPath">Input file</param>
        /// <param name="d8Path">Input file</param>
        /// <param name="areaD8Path">Input file</param>
        /// <param name="outletsPath">Input file</param>
        /// <param name="streamGridResultPath">Output file</param>
        /// <param name="streamOrdResultPath">Output file</param>
        /// <param name="streamShapeResultPath">Output file</param>
        /// <param name="watershedGridResultPath">Output file</param>
        /// <param name="coordDatResultPath">Output file</param>
        /// <param name="treeDatResultPath">Output file</param>
        /// <param name="useOutlets">Use outlets</param>
        /// <param name="numProcesses">Number of processes</param>
        /// <param name="showTaudemOutput">Show taudem output</param>
        /// <param name="callback">Callback objet</param>
        /// <returns>
        /// Taudem return number, 0 means OK
        /// </returns>
        public static int RunStreamOrderGridRaster(
            string demGridPath,
            string pitFillPath,
            string d8Path,
            string areaD8Path,
            string outletsPath,
            string streamGridResultPath,
            string streamOrdResultPath,
            string streamShapeResultPath,
            string watershedGridResultPath,
            string coordDatResultPath,
            string treeDatResultPath,
            bool useOutlets,
            int numProcesses,
            bool showTaudemOutput,
            IProgressHandler callback)
        {
            Trace.WriteLine("Stream Order Grid and Raster");
            if (callback != null)
            {
                callback.Progress("Status", 0, "Stream Order Grid and Raster");
            }

            //DataManagement.DeleteGrid(streamOrdResultPath);
            //DataManagement.DeleteGrid(streamShapeResultPath);
            //DataManagement.DeleteGrid(watershedGridResultPath);

            File.Delete(coordDatResultPath);
            File.Delete(treeDatResultPath);

            var pars = "-fel " + Quote(pitFillPath) + " -p " + Quote(d8Path) + " -ad8 " + Quote(areaD8Path) + " -src "
                   + Quote(streamGridResultPath) + " -ord " + Quote(streamOrdResultPath) + " -tree "
                   + Quote(treeDatResultPath) + " -coord " + Quote(coordDatResultPath) + " -net "
                   + Quote(streamShapeResultPath) + " -w " + Quote(watershedGridResultPath);
            if (useOutlets)
            {
                pars += " -o " + Quote(outletsPath);
            }

            var result = RunTaudem("StreamNet.exe", pars, numProcesses, showTaudemOutput);
            if (result == -1)
            {
                if (!File.Exists(streamOrdResultPath))
                {
                    MessageBox.Show(
                        "Automatic Watershed Delineation encountered an error which generally occurs from too many outlets/inlets being delineated, especially ones close together. Please lower the snap threshold and rerun to minimize outlets/inlets not direclty on the streams.",
                        "Application Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
            else
            {
                if (result != 0)
                {
                    MessageBox.Show(
                        "TauDEM Error " + result,
                        "TauDEM Error " + result,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }

            //CopyProjectionFromGrid(demGridPath, streamGridResultPath);
            //CopyProjectionFromGrid(demGridPath, streamOrdResultPath);
            //CopyProjectionFromGrid(demGridPath, watershedGridResultPath);

            DataManagement.TryCopy(
                Path.ChangeExtension(demGridPath, ".prj"), Path.ChangeExtension(streamShapeResultPath, ".prj"));

            if (callback != null)
            {
                callback.Progress("Status", 0, string.Empty);
            }

            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:100,代码来源:Hydrology.cs

示例10: File_Fill


//.........这里部分代码省略.........
        //        /// </summary>
        //        /// <param name="mwSourceGrid">Raster object to Fill</param>
        //        /// <param name="mwDestGrid">
        //        /// Raster object Output.
        //        /// Specifies output filename and extents.  Everything else will be obtained from original grid.
        //        /// </param>
        //        /// <param name="ShowProgressDialog">
        //        /// Boolean.  Function will display a dialog depicting progress if true.
        //        /// </param>
        //        /// /// <remarks>
        //        /// Images too large to process all at once are broken down into a framework.
        //        /// A frame represents what will be loaded into memory at any given time.
        //        /// </remarks>
        //        public static void Fill(Raster mwSourceGrid, Raster mwDestGrid, bool ShowProgressDialog)
        //        {
        //            // 10000 width
        //            // 2000 height
        //           Trace.WriteLine("Fill(sourceGrid: " + mwSourceGrid.Filename + ",\n" +
        //                                     "      mwDestGrid: " + mwDestGrid.Filename + ",\n" +
        //                                     "      ShowProgressDialog: " + ShowProgressDialog.ToString());
        //            DoFill(mwSourceGrid, mwDestGrid, ShowProgressDialog, 10000, 2000, null);
        //        }

        /// <summary>
        /// Internal File handling
        /// </summary>
        /// <param name="sourceFile">The Source File. </param>
        /// <param name="destFile">The Dest File. </param>
        /// <param name="overwrite">The Overwrite. </param>
        /// <param name="showProgressDialog">The Show Progress Dialog. </param>
        /// <param name="frameWidth">The Frame Width. </param>
        /// <param name="frameHeight">The Frame Height. </param>
        /// <param name="callBack">The CallBack. </param>
        private static void File_Fill(string sourceFile, string destFile, bool overwrite, bool showProgressDialog, int frameWidth, int frameHeight, IProgressHandler callBack)
        {
            Trace.WriteLine("Fill(sourceGrid: " + sourceFile + ",\n" +
                            "     mwDestFile: " + destFile + ",\n" +
                            "     Overwrite: " + overwrite + ",\n" +
                            "     ShowProgressDialog: " + showProgressDialog + ",\n" +
                            "     FrameWidth: " + frameWidth + ", \n" +
                            "     FrameHeight: " + frameHeight + ", \n" +
                            "     IProgressHandler");

            if (callBack != null)
            {
                callBack.Progress("Status", 0, "Opening Files");
            }

            var pars = "-z " + Quote(sourceFile) + " -fel " + Quote(destFile);
            var result = RunTaudem("PitRemove.exe", pars, 1, false);
            //todo use tdbChoiceList.numProcesses, tdbChoiceList.ShowTaudemOutput,

            if (result != 0)
            {
                MessageBox.Show(
                    "TauDEM Error " + result,
                    "TauDEM Error " + result,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }

            //var sourceRaster = Raster.Open(sourceFile);

            //if (File.Exists(destFile))
            //{
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:67,代码来源:Hydrology.cs

示例11: RunAllStreamDelineation

        /// <summary>Runs threshold.exe</summary>
        /// <param name="areaD8Path">Input file</param>
        /// <param name="streamGridResultPath">Output file</param>
        /// <param name="threshold">The threshold</param>
        /// <param name="numProcesses">Number of processes</param>
        /// <param name="showTaudemOutput">Show taudem output</param>
        /// <param name="callback">Callback objet</param>
        /// <returns>Taudem return number, 0 means OK</returns>
        /// <remarks>Created by Paul Meems, 23 Aug 2011</remarks>
        public static int RunAllStreamDelineation(
            string areaD8Path,
            string streamGridResultPath,
            int threshold,
            int numProcesses,
            bool showTaudemOutput,
            IProgressHandler callback)
        {
            Trace.WriteLine("All Stream Delineation");
            if (callback != null)
            {
                callback.Progress("Status", 0, "All Stream Delineation");
            }

            //DataManagement.DeleteGrid(streamGridResultPath);

            var areaGridPath = areaD8Path; // TODO CWG inf does not seems to work (useDinf)?areaDInfPath:areaD8Path;
            var pars = "-ssa " + Quote(areaGridPath) + " -src " + Quote(streamGridResultPath) + " -thresh "
                   + threshold.ToString(CultureInfo.InvariantCulture);
            var result = RunTaudem("threshold.exe", pars, numProcesses, showTaudemOutput);
            if (result != 0)
            {
                MessageBox.Show(
                    "TauDEM Error " + result,
                    "TauDEM Error " + result,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:40,代码来源:Hydrology.cs

示例12: RunGridNetwork


//.........这里部分代码省略.........

        //            streamGridResElem.Caption = "Stream Raster Grid Result Path";
        //            streamGridResElem.HelpButtonVisible = false;

        //            wshedGridResElem.Caption = "Watershed Grid Result Path";
        //            wshedGridResElem.HelpButtonVisible = false;

        //            streamShapeResElem.Caption = "Stream Shapefile Result Path";
        //            streamShapeResElem.HelpButtonVisible = false;

        //            treeDatResElem.Caption = "Network Tree Result Data File Path";
        //            treeDatResElem.Filter = "Data Files (*.dat)|*.dat";
        //            treeDatResElem.HelpButtonVisible = false;

        //            coordDatResElem.Caption = "Network Coordinates Result Data File Path";
        //            coordDatResElem.Filter = "Data Files (*.dat)|*.dat";
        //            coordDatResElem.HelpButtonVisible = false;

        //            numProcessesElem.Caption = "Number of processes";
        //            numProcessesElem.Text = "8";
        //            numProcessesElem.HelpButtonVisible = false;

        //            showTaudemOutputElem.Caption = "Show Taudem output";
        //            showTaudemOutputElem.Text = "Show Taudem output";
        //            showTaudemOutputElem.HelpButtonVisible = false;

        //            if (delinstreamDiag.ShowDialog() == DialogResult.OK)
        //            {
        //                //TODO add stream shape and watershed grid
        //                return DelinStreamGrids(demElem.Filename, fillElem.Filename, d8Elem.Filename, d8slpElem.Filename, aread8Elem.Filename, areadinfElem.Filename, outletsElem.Filename, strahlResElem.Filename, longestResElem.Filename, totalResElem.Filename, streamGridResElem.Filename, streamOrdResElem.Filename, treeDatResElem.Filename, coordDatResElem.Filename, streamShapeResElem.Filename, wshedGridResElem.Filename, int.Parse(threshElem.Value), useOutletsElem.Value, useEdgeElem.Value, usedinfElem.Value, Int32.Parse(numProcessesElem.Value), showTaudemOutputElem.Value, callback);
        //            }
        //            return -2;
        //        }

        /// <summary>
        /// Runs GridNet.exe
        /// </summary>
        /// <param name="demGridPath">Input file</param>
        /// <param name="d8Path">Input file</param>
        /// <param name="longestUpslopeResultPath">Output file</param>
        /// <param name="totalUpslopeResultPath">Output file</param>
        /// <param name="strahlOrdResultPath">Output file</param>
        /// <param name="outletsPath">Input file</param>
        /// <param name="useOutlets">Use outlets</param>
        /// <param name="numProcesses">Number of processes</param>
        /// <param name="showTaudemOutput">Show taudem output</param>
        /// <param name="callback">Callback objet</param>
        /// <returns>
        /// Taudem return number, 0 means OK
        /// </returns>
        public static int RunGridNetwork(
            string demGridPath,
            string d8Path,
            string longestUpslopeResultPath,
            string totalUpslopeResultPath,
            string strahlOrdResultPath,
            string outletsPath,
            bool useOutlets,
            int numProcesses,
            bool showTaudemOutput,
            IProgressHandler callback)
        {
            Trace.WriteLine("Grid Network");
            if (callback != null)
            {
                callback.Progress("Status", 0, "Grid Network");
            }

            //DataManagement.DeleteGrid(strahlOrdResultPath);
            //DataManagement.DeleteGrid(longestUpslopeResultPath);
            //DataManagement.DeleteGrid(totalUpslopeResultPath);

            var pars = "-p " + Quote(d8Path) + " -plen " + Quote(longestUpslopeResultPath) + " -tlen "
                       + Quote(totalUpslopeResultPath) + " -gord " + Quote(strahlOrdResultPath);
            if (useOutlets)
            {
                pars += " -o " + Quote(outletsPath);
            }

            var result = RunTaudem("GridNet.exe", pars, numProcesses, showTaudemOutput);
            if (result != 0)
            {
                MessageBox.Show(
                    "TauDEM Error " + result,
                    "TauDEM Error " + result,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            //CopyProjectionFromGrid(demGridPath, strahlOrdResultPath);
            //CopyProjectionFromGrid(demGridPath, longestUpslopeResultPath);
            //CopyProjectionFromGrid(demGridPath, totalUpslopeResultPath);

            if (callback != null)
            {
                callback.Progress("Status", 0, string.Empty);
            }

            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例13: AreaD8


//.........这里部分代码省略.........
        //                                            {
        //                                                gridDem.set_Value(y, x, setVal);
        //                                            }
        //                                        }
        //                                    }
        //                                }
        //                            }

        //                            err = err + deltaerr;
        //                            if (2 * err < deltax)
        //                            {
        //                                continue;
        //                            }

        //                            y = y + ystep;
        //                            err = err - deltax;
        //                        }
        //                    }
        //                }

        //               Trace.WriteLine("Finished Mask");
        //            }

        //            gridDem.Save(burnedDemResultPath, GridFileType.UseExtension, null);
        //            const int Result = 0;
        //            lineShape.Close();

        //            gridDem.Close();

        //            gridTrack.Close();

        //            if (callback != null)
        //            {
        //                callback.Progress("Status", 0, string.Empty);
        //            }

        //            DataManagement.DeleteGrid(strGridTrack);
        //           Trace.WriteLine("Finished CanyonBurnin");
        //            return Result;
        //        }
        //        #endregion

        //        #region "AreaD8"
        /// <summary>
        /// Uses TauDEM V5
        /// Generates an area D8 grid which shows the paths of highest flow and can be used to delineate stream networks.
        /// </summary>
        /// <param name="d8Path">Path to a D8 grid to be converted into an area D8 grid.</param>
        /// <param name="outletsPath">Optional path to a point shape file which is used to designate outlet points on a grid. If this path is given, the resulting area D8 grid will only include values for those areas of the grid which flow into the outlet points given. All other portions of the grid will be set to 0.</param>
        /// <param name="areaD8ResultPath">Path to an area D8 output grid, </param>
        /// <param name="useOutlets">Boolean true for using outlets in delineation d8 areas</param>
        /// <param name="useEdgeContamCheck">Boolean true to ignore off-grid contributing area</param>
        /// <param name="numProcesses">Number of threads to be used by Taudem</param>
        /// <param name="showTaudemOutput">Show Taudem output if true</param>
        /// <param name="callback"> A callback object for internal status messages</param>
        /// <returns>Integer representing successful creation on 0 or some error state otherwise.</returns>
        public static int AreaD8(string d8Path, string outletsPath, string areaD8ResultPath, bool useOutlets, bool useEdgeContamCheck, int numProcesses, bool showTaudemOutput, IProgressHandler callback)
        {
            Trace.WriteLine("AreaD8(d8Path: " + d8Path + ",\n" +
                                      "       outletsPath: " + outletsPath + ",\n" +
                                      "       AreaD8ResultPath: " + areaD8ResultPath + ",\n" +
                                      "       useOutlets: " + useOutlets + ",\n" +
                                      "       useEdgeContamCheck: " + useEdgeContamCheck + "\n" +
                                      "       NumProcesses: " + numProcesses + "\n" +
                                      "       ShowTaudemOutput: " + showTaudemOutput + "\n" +
                                      "       callback)");

            // DataManagement.DeleteGrid(areaD8ResultPath);

            if (callback != null)
            {
                callback.Progress("Status", 0, "D8 Area");
            }

            var pars = "-p " + Quote(d8Path) + " -ad8 " + Quote(areaD8ResultPath);
            if (useOutlets)
            {
                pars += " -o " + Quote(outletsPath);
            }

            if (!useEdgeContamCheck)
            {
                pars += " -nc";
            }

            var result = RunTaudem("AreaD8.exe", pars, numProcesses, showTaudemOutput);
            if (result != 0)
            {
                MessageBox.Show("TauDEM Error " + result, "TauDEM Error " + result, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // CopyProjectionFromGrid(d8Path, areaD8ResultPath);
            if (callback != null)
            {
                callback.Progress("Status", 0, string.Empty);
            }

            Trace.WriteLine("Finished AreaD8");
            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Hydrology.cs

示例14: ApplyJoinBasinAreaAttributes

        //        #endregion

        //        #region "Apply Joined Basin Attributes"
        /// <summary>
        /// A function to apply attributes to a joined basin shapefile
        /// </summary>
        /// <param name="JoinBasinShapePath"></param>
        /// <param name="elevUnits"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static bool ApplyJoinBasinAreaAttributes(string JoinBasinShapePath, ElevationUnits elevUnits, IProgressHandler callback)
        {
            if (callback != null) callback.Progress("Status", 0, "Calculating Merge Shed Area Attributes");
            double currarea;
            double aream;
            double areasqmi;
            double areaacre;

            int oldperc = 0;
            int newperc = 0;
            var mergeshed = FeatureSet.Open(JoinBasinShapePath);

            int areamfieldnum = mergeshed.DataTable.Columns.Count;
            mergeshed.DataTable.Columns.Add("Area_M", typeof(double));

            int areaacfieldnum = mergeshed.DataTable.Columns.Count;
            mergeshed.DataTable.Columns.Add("Area_Acre", typeof(double));

            int areasqmifieldnum = mergeshed.DataTable.Columns.Count;
            mergeshed.DataTable.Columns.Add("Area_SqMi", typeof(double));

            var projection = mergeshed.Projection;
            for (int i = 0; i <= mergeshed.NumRows() - 1; i++)
            {
                if (mergeshed.NumRows() > 1)
                {
                    newperc = Convert.ToInt32((Convert.ToDouble(i) / Convert.ToDouble(mergeshed.NumRows())) * 100);
                    if ((newperc > oldperc))
                    {
                        if (callback != null) callback.Progress("Status", newperc, "Calculating Merge Shed Area Attributes");
                        oldperc = newperc;
                    }
                }

                IFeature currShape = mergeshed.get_Shape(i);
                currarea = Utils.AreaOfPart(currShape, 0);
                aream = 0;
                if (projection != null)
                {
                    if ((projection.Unit.Name == "Meter"))
                    {
                        aream = currarea;
                    }
                    else if ((projection.Unit.Name == "Foot"))
                    {
                        aream = currarea * 0.09290304;
                    }
                }
                else
                {
                    aream = currarea;
                }
                areaacre = aream * 0.000247105;
                areasqmi = areaacre * 0.0015625;
                mergeshed.EditCellValue(areamfieldnum, i, aream);
                mergeshed.EditCellValue(areaacfieldnum, i, areaacre);
                mergeshed.EditCellValue(areasqmifieldnum, i, areasqmi);
            }
            mergeshed.Save();
            mergeshed.Close();

            if (callback != null) callback.Progress(String.Empty, 0, String.Empty);
            return true;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:74,代码来源:Hydrology.cs

示例15: D8

        /// <summary>
        /// Uses TauDEM V5
        /// Generates a D8 directional grid by assigning a number from 1 to 8 (0 to 7 in some algorithms) based on a direction to the lowest elevation cell surrounding that cell.
        /// </summary>
        /// <param name="pitFillPath">Path of a pit-filled DEM.</param>
        /// <param name="d8ResultPath">Output result file of a D8 directional grid.</param>
        /// <param name="d8SlopeResultPath">Path to an output grid containing the slope from the cell to the lowest elevation surrounding cell.</param>
        /// <param name="numProcesses">Number of threads to be used by Taudem</param>
        /// <param name="showTaudemOutput">Show Taudem output if true</param>
        /// <param name="callback"> A callback object for internal status messages</param>
        /// <returns>Integer representing successful creation on 0 or some error state otherwise.</returns>
        public static bool D8(string pitFillPath, string d8ResultPath, string d8SlopeResultPath, int numProcesses, bool showTaudemOutput, IProgressHandler callback)
        {
            Trace.WriteLine("D8(pitFillPath: " + pitFillPath + "\n" +
                            "   D8ResultPath: " + d8ResultPath + "\n" +
                            "   D8SlopeResultPath: " + d8SlopeResultPath + "\n" +
                            "   NumProcesses: " + numProcesses.ToString() + "\n" +
                            "   ShowTaudemOutput: " + showTaudemOutput.ToString() + "\n" +
                            "   callback)");
            if (callback != null)
            {
                callback.Progress("Status", 0, "D8 Flow Directions");
            }

            //DataManagement.DeleteGrid(d8ResultPath);
            //DataManagement.DeleteGrid(d8SlopeResultPath);

            var pars = "-p " + Quote(d8ResultPath) + " -sd8 " + Quote(d8SlopeResultPath) + " -fel " + Quote(pitFillPath);
            var result = RunTaudem("D8FlowDir.exe", pars, numProcesses, showTaudemOutput);

            if (result != 0)
            {
                MessageBox.Show(
                    "TauDEM Error " + result,
                    "TauDEM Error " + result,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }

            //CopyProjectionFromGrid(pitFillPath, d8ResultPath);
            //CopyProjectionFromGrid(pitFillPath, d8SlopeResultPath);
            if (callback != null)
            {
                callback.Progress("Status", 0, string.Empty);
            }

            Trace.WriteLine("Finished D8");
            return result == 0;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:50,代码来源:Hydrology.cs


注:本文中的IProgressHandler.Progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。