I have a Shapefile that contains several thousand polygons.
I need to read from this file in C # and list the WKT formatted strings.
I looked at DotSpatial and the "CatFood" ESRI Shapefile Reader . I can get or load the shapefile just fine, but I cannot figure out how to export it as WKT then.
In DotSpatial, the only examples I could find use WktWriterthat accepts Geometry. I could not figure out how to get Geometryfrom Shape.
Is there a library that is more suitable for this?
Update
Thanks to mdm20's answer, I was able to write the following:
using (var fs = FeatureSet.Open(path))
{
var writer = new WktWriter();
var numRows = fs.NumRows();
for (int i = 0; i < numRows; i++)
{
var shape = fs.GetShape(i, true);
var geometry = shape.ToGeometry();
var wkt = writer.Write((Geometry) geometry);
Debug.WriteLine(wkt);
}
}
, , , , fs.ShapeIndices fs.GetShape(). Shape, a ShapeRange, .
fs.IndexMode = true? ? , .fs.GetShape() getAttributes. , , , , true false. , . ?- , WKT , ? - ? - dotSpatial ?
- , , - . .prj. dotSpatial , - - ?
!