I have an Esri shape file with 10 polygons in it.
I need to read the shape file, correlated the polygons to their associated names (the .dbf table lists the Name of each polygon and its "key").
But... I can't seem to get the reader to return the polygons. Here's what I've got for code:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var shpPath = @".\Esri\RootNameOfShapeFile";
var geoFactory = GeometryFactory.Floating;
var reader = Shapefile.CreateDataReader(shpPath, geoFactory);
Console.WriteLine(reader.RecordCount); // outputs 10 which is correct
Console.WriteLine(reader.FieldCount); // outputs 6 which is correct
Console.WriteLine(reader.DbaseHeader.Fields[0].Name); // outputs "name" which is correct
while (reader.Read())
{
Console.WriteLine(reader.Geometry.ToString()); // Nothing written. Reader.Read() always false
}
Console.WriteLine("Hello, World!");
Halp
NetTopologySuite.IO.ShapeFile
is deprecated. You should use NetTopologySuite.IO.Esri
.