How to save and load shape file in V2.0?

Topics: SharpMap Project, SharpMap v2.0
Jul 2, 2008 at 6:44 PM
My project currently uses SharpMap 0.9, but I recently learned about SharpMap 2.0.  I saw some pictures of the new maps generated from SharpMap 2.0, and they look really good.  I want to get those maps into my project so I downloaded and compiled version 2.0 with no problem.  I am trying to build a test project to do two things.  1) Save those maps I saw in demo into shape files.   2) Load those saved shape files back into SharpMap.  There was no functions to save shape files in version 0.9 so I can't try to do the same in 2.0, but there is functions to load shape file; however, the functions calls for are not there in 2.0.  Can someone give me some on how to get those two things working?  Or point me in the right direction to look for the functions.  Thank you very much in advance.

Jul 3, 2008 at 10:37 AM
Hi Lynn, I havent done anything with writing shapefiles yet, but to read them you need to create an instance of ShapeFileProvider. In order to render a layer you need to assign your shapefile provider to the Datasource property of a GeometryLayer. Currently you will have issues if you have prj files with your shapefiles or require any reprojection.

Note as you go along you will notice that many classes take IGeometryFactory as a constructor parameter.
It is worth creating a set of factories (ICoordinateFactory, ICoordinateSequenceFactory...IGeometryFactory) and making them available globally. Concrete implementations of these interfaces can be found in the ManagedBufferedCoordinate2D project (part of NTS) and GeometryFactory is in NTS.

There is a scratch demo project at: which may give you some ideas, however the latest source has probably changed since that project was created so it may take a bit of tweaking to run.. hth jd