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


C# FeatureSet.Close方法代码示例

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


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

示例1: MapRasterToTriangulation


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

                                if (m > -1)
                                {
                                    rasterWaterSurfaceMapping[i][j] = k;
                                    mapping[j * xSize + i] = k;
                                    rasterTriangleMapping[i][j] = m;
                                }
                            }
                        }
                    }
                }
                coordinates.Add(coordinate);
            }
        }

        using(IFeatureSet set = new FeatureSet(FeatureType.MultiPoint))
        {
            foreach(var p in coordinates)
            set.AddFeature(new MultiPoint(p));

            set.SaveAs(localWorkspace + "\\" + name + "_point.shp", true);
        }
        //);

        OSGeo.GDAL.Driver driver = Gdal.GetDriverByName(rasterDriver);
        Dataset newRaster = driver.Create(localWorkspace + "\\" + name + "_mapping.tif", xSize, ySize, 1, dataType, new string[] { "TFW=YES", "COMPRESS=LZW" });
        newRaster.GetRasterBand(1).SetNoDataValue(noData);
        newRaster.SetGeoTransform(geoTransformation);
        newRaster.SetProjection(projection);

        Band newRasterBand = newRaster.GetRasterBand(1);
        newRasterBand.WriteRaster(0, 0, xSize, ySize, mapping, xSize, ySize, 0, 0);
        double min, max, mean, stdev;
        newRasterBand.GetStatistics(0, 1, out min, out max, out mean, out stdev);
        newRasterBand.FlushCache();
        newRaster.FlushCache();
        newRaster.Dispose();
        newRaster = null;

        driver.Dispose();
        driver = null;

        using (IFeatureSet fs = new FeatureSet(DotSpatial.Topology.FeatureType.Polygon))
        {
            fs.DataTable.Columns.AddRange(new DataColumn[]
                    {
                      new DataColumn("Identifier" , typeof(int)),
                    });

            int tcount = 0;

            for (int k = 0; k < waterSurfacePolygons.Count; k++)
            {
                WaterSurfacePolygon surface = waterSurfacePolygons[k];

                foreach (TriangleNet.Data.Triangle pgon in surface.Triangles)
                {
                    TriangleNet.Data.Triangle ts = pgon;
                    List<Coordinate> vertices = new List<Coordinate>();

                    Point p0 = surface.Points[ts.P0];
                    Point p1 = surface.Points[ts.P1];
                    Point p2 = surface.Points[ts.P2];

                    Coordinate c1 = new Coordinate(p0.X, p0.Y, p0.Z);
                    Coordinate c2 = new Coordinate(p1.X, p1.Y, p1.Z);
                    Coordinate c3 = new Coordinate(p2.X, p2.Y, p2.Z);

                    vertices.Add(c1);
                    vertices.Add(c2);
                    vertices.Add(c3);

                    Polygon polygon = new Polygon(vertices);

                    IFeature fset = fs.AddFeature(polygon);

                    fset.DataRow.BeginEdit();

                    fset.DataRow["Identifier"] = k;

                    fset.DataRow.EndEdit();

                    tcount++;
                }
            }

            fs.SaveAs(localWorkspace + "\\" + name + "_polygon.shp", true);
            fs.Close();
            fs.Dispose();
        }

        double temp = 100;
        Console.SetCursorPosition(0, Console.CursorTop);
        Console.WriteLine("Progress => " + temp.ToString("###") + " % \n");

        temp = foundCount * 100.0 / (xSize * ySize * 1.0);
        Console.WriteLine(temp.ToString("###.0") + " %  of pixels were found in triangulation \n");

        Console.WriteLine("Finished mapping elevation raster pixels to triangulation !\n");
    }
开发者ID:calebbuahin,项目名称:RCAFF,代码行数:101,代码来源:ForeCastConfiguration.cs

示例2: BuildJoinedBasins


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

                    shapeIdxList.Clear();
                    if (drainage != null)
                    {
                        char[] sep = { ',' };
                        var idxs = drainage.ToString().Split(sep);
                        for (var i = 0; i < idxs.Length; i++)
                        {
                            shapeIdxList.Add(idxs[i]);
                        }
                    }

                    if (shapeIdxList.Count != 0)
                    {
                        IFeature mergeShape;
                        string strLinks;
                        if (shapeIdxList.Count == 1)
                        {
                            mergeShape = shed.get_Shape(int.Parse(shapeIdxList[0].ToString()));
                            strLinks = shed.get_CellValue(0, int.Parse(shapeIdxList[0].ToString())).ToString();
                        }
                        else
                        {
                            strLinks = shed.get_CellValue(0, int.Parse(shapeIdxList[0].ToString())).ToString();
                            for (int i = 1; i <= shapeIdxList.Count - 1; i++)
                            {
                                strLinks = strLinks + ", " + shed.get_CellValue(0, int.Parse(shapeIdxList[i].ToString()));
                            }

                            DateTime time = DateTime.Now;
                            mergeShape = mergeBasinsByDrainage(shed, drainage);
                            var elapsed = DateTime.Now.Subtract(time);
                            Trace.WriteLine("Made merged watershed of " + shapeIdxList.Count +
                                                      " subbasins in " + elapsed.TotalSeconds.ToString("F1") + " seconds");
                        }

                        // Check merged shape for single part and clockwise
                        if (mergeShape.NumGeometries > 1)
                        {
                            Trace.WriteLine("Merged polygon has " + mergeShape.NumGeometries + " parts");
                        }
                        else
                        {
                            var area = SignedArea(mergeShape);
                            if (area < 0)
                            {
                                Trace.WriteLine("Needed to reverse merged polygon");
                                mergeShape = ReverseShape(mergeShape);
                            }
                        }

                        var currshpidx = newShed.NumRows();
                        newShed.AddFeature(mergeShape);
                        newShed.EditCellValue(idfieldnum, currshpidx, currshpidx);
                        newShed.EditCellValue(linkfieldnum, currshpidx, strLinks);
                        newShed.EditCellValue(outletfieldnum, currshpidx, dsNodeVal);
                        if (int.Parse(shed.get_CellValue(dsShedFieldNum, sindx).ToString()) != -1)
                        {
                            newShed.EditCellValue(dswsfieldnum, currshpidx, shed.get_CellValue(dsShedFieldNum, sindx));
                        }
                        else
                        {
                            newShed.EditCellValue(dswsfieldnum, currshpidx, -1);
                        }

                        newShed.EditCellValue(uswsfieldnum1, currshpidx, -1);
                        newShed.EditCellValue(uswsfieldnum2, currshpidx, -1);
                        if (dsNodeType == DSNode.Reservoir)
                        {
                            newShed.EditCellValue(reservoirfieldnum, currshpidx, 1);
                        }
                        else
                        {
                            newShed.EditCellValue(reservoirfieldnum, currshpidx, 0);
                        }
                    }
                }
            }

            buildMergeDownstreamUpStream(newShed, idfieldnum, linkfieldnum, dswsfieldnum, uswsfieldnum1, uswsfieldnum2);

            newShed.Projection = shed.Projection;

            shed.Close();

            newShed.Save();
            newShed.Close();

            if (outletsShapePath != string.Empty)
            {
                outlets.Close();
            }

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

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


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