CreateAttributes - sindizzy/DSW GitHub Wiki
// See comments below this code for an updated version.// define the feature type for this file FeatureSet fs = new FeatureSet( FeatureType.Polygon );
// Add Some Columns fs.DataTable.Columns.Add( new DataColumn( "ID", typeof( int ))); fs.DataTable.Columns.Add( new DataColumn( "Text", typeof( string )));
// create a geometry (square polygon)
List<Coordinate> vertices = new List<Coordinate>();
vertices.Add(new Coordinate(0, 0));
vertices.Add(new Coordinate(0, 100));
vertices.Add(new Coordinate(100, 100));
vertices.Add(new Coordinate(100, 0));
Polygon geom = new Polygon(vertices);
// add the geometry to the featureset.
IFeature feature = fs.AddFeature(geom);
// now the resulting features knows what columns it has
// add values for the columns
feature.DataRow.BeginEdit();
feature.DataRow["ID"] = 1;
feature.DataRow["Text"] = "Hello World";
feature.DataRow.EndEdit();// save the feature set fs.SaveAs("d:\test.shp", true);