ITHCWY: Robert Ellison's Blog

ESRI Shapefile Reader in .NET

I've just released a .NET library for parsing ESRI shapefiles - see ESRI Shapefile Reader on Codeplex. The library and source code are available under the Microsoft Public License.

A Shapefile is actually at least three files: a main file containing shape data (*.shp), an index file for locating shape records in the main file (*.shx) and a database of metadata for each shape (*.dbf) in dBASE format.

I ended up writing the library in order to convert Eric Muller's time zone shapefile into a format I could use with Catfood Earth. I found other libraries that could read shape data but not metadata, or provided a very thin .NET wrapper on top of unmanaged code and so I decided that a fully managed library could be useful.

The library - Catfood.Shapefile.dll - provides read-only, forward-only access to shapes and shape metadata. Currently all 2D shapes are supported: Null, Point, MultiPoint, PolyLine and Polygon. I might add additional types in the future, or if you have a pressing need it would be easy to extend the library by looking at an existing shape subclass and the shapefile specification (PDF).

See the Codeplex project for sample code and documentation.

Add Comment

All comments are moderated to weed out spam. Email address is optional and is only used to display your Gravatar.