https://github.com/substack/shp2json
$ npm install -g shp2json
https://github.com/mapbox/geobuf
npm install -g geobuf
In order to install the geobuf-to-grid in the next step, we need to install node-canvas first. https://github.com/Automattic/node-canvas
You can quickly install the dependencies by using the command for your OS:
OS | Command |
---|---|
OS X | brew install pkg-config cairo pango libpng jpeg giflib |
Ubuntu | sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ |
Fedora | sudo yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel |
Solaris | pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto |
Windows | Instructions on our wiki |
El Capitan users: If you have recently updated to El Capitan and are experiencing trouble when compiling, run the following command: xcode-select --install
. Read more about the problem on Stack Overflow.
And then install node-canvas
$ npm install canvas
https://github.com/conveyal/geobuf-to-grid
$ npm install geobuf-to-grid
Firstly, we need zip the whole shapefile into one zip archives
$ shp2json data.zip data.json
$ json2geobuf data.json > data.pbf
Go to the folder you install geobuf-to-grid, and go to the subfolder named "build" Copy the data.pbf you get from step 6 to this "build" folder And enter the following command
$ node geobuf-to-grid.js --png data.pbf data
The last parameter is the output prefix.
Creates one .grid file for each numeric attribute in the geobuf. If --png is specified, creates log-scaled pngs as well (useful for debugging).
- Nodejs 6.9.2
- NPM 3.10.9
- MAC OS 10.12
Converting New Orleans shapefile with 28031 features and 9 fields costs 8 min.