Skip to content
forked from mbostock/shapefile

A streaming parser for the ESRI Shapefile spatial data format.

License

Notifications You must be signed in to change notification settings

lyguy/shapefile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Streaming Shapefile Parser

Based on the ESRI Shapefile Technical Description and dBASE Table File Format.

Caveat emptor: this library is a work in progress and does not currently support all shapefile geometry types (see shp.js for details). It also only supports dBASE III and has no error checking. Please contribute if you want to help!

Reading a Shapefile

The main API for reading a shapefile is shapefile.readStream. This returns an event emitter which emits three types of events:

  • feature - while reading features from the shapefile
  • end - when all features have been read
  • error - if an error occurs

Features are emitted as GeoJSON features, not as shapefile primitives. That’s because GeoJSON objects are the standard representation of geometry in JavaScript, and they are convenient. If you want to access the shapefile primitives directly, use the private shp and dbf classes instead.

See index-test for an example converting a shapefile to a GeoJSON feature collection.

About

A streaming parser for the ESRI Shapefile spatial data format.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%