I'm trying to create a shapefile, but every time I get some kind of error. I'm tried use DotSpatial and NetTopologySuite libraries too, but it still not working.
I'm tried do with ShapefileDataWriter but i get exception (System.ApplicationException: 'Header must be set first!') how can I solve it?
using System;
using System.IO;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
namespace SHP
{
class Program
{
static void Main(string[] args)
{
string filePath = Path.Combine(@"D:\SHP", "point_Created.shp");
var featureCollection = new FeatureCollection();
var geometryFactory = new GeometryFactory();
var header = new ShapefileHeader();
var point = geometryFactory.CreatePoint(new Coordinate(10, 20)); // x,y coordinates of the point
var attributes = new AttributesTable { { "Name", "My Point" } };
var feature = new Feature(point, attributes);
featureCollection.Add(feature);
var writer = new ShapefileDataWriter(filePath);
writer.Write(featureCollection); //System.ApplicationException:'Header must be set first!'
}
}
}