您可以创建Feature变量,然后更新DataRow属性上的内容。然后,您必须直接将功能添加到功能集合,而不是使用AddFeature快捷方法。
// Create a feature set of type Polygon and set the projection
FeatureSet fs = new FeatureSet(FeatureType.Polygon);
fs.Projection = ProjectionInfo.FromAuthorityCode(“EPSG”, 3857);
// Get the DataTable and set the fertilizer field
DataTable table = fs.DataTable;
DataColumn FertilizerField = table.Columns.Add("Fertilizer Value", typeof(double));
// Adding a Polygon feature to the layer
Coordinate[] coord = new Coordinate[]
{
new Coordinate(0.0, 0.0),
new Coordinate(1.0, 0.0),
new Coordinate(1.0, 1.0),
new Coordinate(0.0, 1.0),
new Coordinate(0.0, 0.0)
};
// Create a Feature Variable to update the shape with attribute content.
Feature f = new Feature(new Polygon(new LinearRing(coord)));
// Modify the data row like any DataTable DataRow object.
f.DataRow["Fertilizer Value"] = 100;
// Add the fully created feature to the list of features directly.
fs.Features.Add(f);
</code>