MultilsFCS - sindizzy/DSW GitHub Wiki

Sample code that demonstrates how to create a Multi Line Feature

using DotSpatial.Data;
using DotSpatial.Geometries;

private void button1_Click(object sender, EventArgs e)
{
    Random rnd = new Random();
    Feature f = new Feature();
    FeatureSet fs = new FeatureSet(f.FeatureType);
    LineString[]() ls = new LineString[2](2);
    for (int ii = 0; ii < 2; ii++)
    {
        Coordinate[]() coord = new Coordinate[5](5);
        for (int i = 0; i < 5; i++)
        {
            coord[i](i) = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
        }
        ls[ii](ii) = new LineString(coord);
    }
    MultiLineString mls = new MultiLineString(ls);
    f = new Feature(mls);
    fs.Features.Add(f);
    fs.SaveAs("C:\\Temp\\test.shp", true);
}