Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Updated Wiki: MultypgFSCS

$
0
0

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

using DotSpatial.Data;
using DotSpatial.Topology;

        privatevoid button1_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();
            Polygon[] pg = new Polygon[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];
                for (int ii = 0; ii < 50; ii++)
                {
                    coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                }
                coord[49] = new Coordinate(coord[0].X, coord[0].Y);
                pg[i] = new Polygon(coord);
                fs.Features.Add(pg[i]);
            }
            fs.SaveAs("C:\\Temp\\test.shp", true);
        }

Viewing all articles
Browse latest Browse all 3973

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>