Home > Software design >  Create Shapefile From WKT failed Using NetTopologySuite.IO.Esri
Create Shapefile From WKT failed Using NetTopologySuite.IO.Esri

Time:08-16

I want to create a shapefile from wkt by using NetTopologySuite.IO.Esri, but get this error like this:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'NetTopologySuite.Geometries.Polygon' to type 'NetTopologySuite.Geo
metries.MultiPolygon'.
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter`1.Write(IFeature feature)
   at NetTopologySuite.IO.Esri.Shapefiles.Writers.ShapefileWriter.Write(IEnumerable`1 features)
   at NetTopologySuite.IO.Esri.Shapefile.WriteAllFeatures(IEnumerable`1 features, String shpPath, Encoding encoding, String projection) 

I try to open the debug mode and tracking code, I found that in Shapefile.cs line 185, there are trying to get the parameter's geometry type like this:

var shapeType = features.FindNonEmptyGeometry().GetShapeType();

And in my situation, it always return PolygonZM

  • Related