Sample code that demonstrates how to create a Mutli Polygon Feature

using DotSpatial.Data;
using DotSpatial.Geometries;

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

Last edited Jul 13, 2010 at 4:12 PM by AlamoMan, version 4