Shapefile C Library


The Shapefile C Library provides the ability to write simple C programs for reading, writing and updating (to a limited extent) ESRI Shapefiles, and the associated attribute file (.dbf).

Supporting Information

What is a Shapefile?

If you don't know, you probably don't need this library. The Shapefile format is a working and interchange format promulagated by ESRI for simple vector data with attributes.

An excellent white paper on the shapefile format is available from ESRI, but it is .pdf format, so you will need Adobe Acrobat to browse it.

The file format actually consists of three files.

XXX.shp - holds the actual vertices.
XXX.shx - hold index data pointing to the structures in the .shp file.
XXX.dbf - holds the attributes in xBase (dBase) format.  


Source code, and some other odds and ends can be downloaded from

Shapelib is available for anonymous CVS access:

  cvs -d login
  Password: (hit enter)
  cvs -d co shapelib

Bugs, Maintainance and Support

This library is maintained by Frank Warmerdam. Please send me bug reports, patches and suggestions for the library via the Bugzilla. Shapelib bugs can also be queried.

Shapelib is hosted at A mailing list for discussion of how to use shapelib, and announcing new releases is available. To only find out about new releases of Shapelib select the "Subscribe to new releases" option from the link at Freshmeat.


I didn't start this section anywhere near soon enough, so alot of earlier contributors to Shapelib are lost in pre-history.

In Memorium

I would like to dedicate Shapelib to the memory of Sol Katz. While I never met him in person, his generous contributions to the GIS community took many forms, including free distribution of a variety of GIS translators with source. The fact that he used this Shapelib in some of his utilities, and thanked me was a great encouragement to me. I hope I can do his memory honour by trying to contribute in a similar fashion.


The Shapefile C Library should port easily to 32bit systems with ANSI C compilers. It should work on 64 bit architectures (such as the DEC AXP).

Care should also be taken to pass the binary access flag into SHPOpen() and DBFOpen() when operating on systems with special text file translation such as MSDOS.

The shputils.c module is contributed, and may not take the same approach to portability as the rest of the package.

On Linux, and most unix systems it should be possible to build and install shapefile support as a shared library using the "lib" and "lib_install" targets of the Makefile. Note that this Makefile doesn't use autoconf mechanisms and will generally require some hand tailoring for your environment.


Other Shapefile Resources