Write and read shapefiles

Feb 23, 2011 at 12:00 AM

I'm using DotSpatial to write and read a shapefile of multipolygon.

When I create the file all polygon are NOT empty.

When I read it, some poygon endup being empty polygon!!

I tracked down the problem to DotSpatial/Data/FeatureSet.cs: FeatureSet.GetPolygon(int index)

To recreate the polygons it find out which line strings are holes and which one are shells from the orientation, and all are holes! (in the empty polygon case)

 

How come, this was correctly read from a WKB into an IGeometry by DotSpatial, how come writing and reading from a shapefile messed it up?

Further, what can I do!?! :(

 

BTW I already try to "fix" the multi polygon by calling Normalize() on each of its polygon, with no result....

Feb 24, 2011 at 2:20 AM

After some wild attempt I "fixed" the IGeometry before writing them just the same way as we in SQL.

i.e.

IGeometry geom = ....
geom = geom.Union(new Point(geom.Coordinates[0]));

 

and then I write it to shapefile and can successfully read them!