在Featureset Dotspatial中设置字段值


v-star*위위
2025-03-12 02:43:24 (9天前)
  1. 我正在使用Microsoft Visual StudioC#编程语言中的DotSpatial库创建shapefile shapefilePolygon图层组成。图层中的每个多边形都需要具有特定的...

2 条回复
  1. 0# 不浪漫罪名 | 2019-08-31 10-32



    您可以创建Feature变量,然后更新DataRow属性上的内容。然后,您必须直接将功能添加到功能集合,而不是使用AddFeature快捷方法。




    1. // Create a feature set of type Polygon and set the projection
      FeatureSet fs = new FeatureSet(FeatureType.Polygon);
      fs.Projection = ProjectionInfo.FromAuthorityCode(“EPSG”, 3857);

    2.     // Get the DataTable and set the fertilizer field
    3.     DataTable table = fs.DataTable;
    4.     DataColumn FertilizerField = table.Columns.Add("Fertilizer Value", typeof(double));
    5.     // Adding a Polygon feature to the layer 
    6.     Coordinate[] coord = new Coordinate[]
    7.     {
    8.         new Coordinate(0.0, 0.0),
    9.         new Coordinate(1.0, 0.0),
    10.         new Coordinate(1.0, 1.0),
    11.         new Coordinate(0.0, 1.0),
    12.         new Coordinate(0.0, 0.0)
    13.     };
    14.     // Create a Feature Variable to update the shape with attribute content.
    15.     Feature f = new Feature(new Polygon(new LinearRing(coord)));
    16.     // Modify the data row like any DataTable DataRow object.
    17.     f.DataRow["Fertilizer Value"] = 100;
    18.     // Add the fully created feature to the list of features directly.
    19.     fs.Features.Add(f);
    20. </code>

登录 后才能参与评论