Best Practices

May 25, 2011 at 2:49 PM

Hello All,


I've been exploring dotspatial for a couple of days, and have come up with a few questions.  I'm interested in extending the LabelLayer into something similar to ESRI annotation.  My initial thought is to use a polygon shapefile for storage.  Unfortunately I'm a bit confused about what the best option for creating a shapefile and attaching to a featureset is.  There seems to be multiple options ShapefileSource, FeatureSource, FeatureSet.Open, PolygonShapefileShape/FeatureSource, ShapefileDataProvider, Shapefile. Any advice on what the best route to take for creating an empty (indexed) shapefile, adding attributes, and features?


Also are there UML diagrams available to show how all the classes are linked up?


Thanks for any help.

May 25, 2011 at 5:43 PM

I don't have time right now to go into a lot of depth, but I'll dispense a little info.

FeatureSets which implement IFeatureSet, load the entire shapefile into memory and are ubiquitous in DotSpatial.  If you don't have memory resource issues, this may be a good one to use.  You can read in a shapefile, save to a shapefile, and add/modify/delete the features in between as well as lots of other things.  There is lots of code in DotSpatial that deals with FeatureSets.

ShapefileShapeSource is an abstract base class for the shapefile types (polygon, line, point) that implement IShapeSource.  This interface is intended for reading geometries only such as in a display path where speed and memory conservation is important.  You don't have access to attributes, nor can you manipulate the data via IShapeSource.  It does not load everything into memory; you request data in pages.  It does support spatial query (by rectangle only).

ShapefileFeatureSource is an abstract base class for the shapefile types (polygon, line, point) that implement IFeatureSource.  This interface is is intended for reading and writing features (geometry + attributes) where memory conservation is important.  These classes will not be as fast as FeatureSets but they require very little memory.  You can query both spatially (by rectangle) and by attribute expression.  You can add/modify/delete features, but each operation goes back to the file with its advantages and disadvantages.

Hope this helps a little bit.



May 26, 2011 at 8:53 PM

Thanks, this is helpful.



Jan 8, 2013 at 10:49 AM

Is there anything similar for rasters? that prevent to load all data into memory


Thank you