MultypgFSCS - sindizzy/DSW GitHub Wiki

Sample code that demonstrates how to create a Multi Polygon Feature Set

using DotSpatial.Data;
using DotSpatial.Topology;

private void button1_Click(object sender, EventArgs e)
{
    Random rnd = new Random();
    Polygon[]() pg = new Polygon[100](100);
    Feature f = new Feature();
    FeatureSet fs = new FeatureSet(f.FeatureType);
    for (int i = 0; i < 100; i++)
    {
        Coordinate center = new Coordinate((rnd.Next(50) * 360) - 180, (rnd.Next(60) * 180) - 90);
        Coordinate[]() coord = new Coordinate[50](50);
        for (int ii = 0; ii < 50; ii++)
        {
            coord[ii](ii) = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
        }
        coord[49](49) = new Coordinate(coord[0](0)(0).X, coord[0](0)(0).Y);
        pg[i](i) = new Polygon(coord);
        fs.Features.Add(pg[i](i));
    }
    fs.SaveAs("C:\\Temp\\test.shp", true);
}