This repo contains scripts for generating vector tiles of all US constituencies, based on data from Who's On First.
The data used here is potentially out of date or incomplete. This code is mainly for educational purposes.
These scripts assume a few basic dependencies. Most of these can be installed through Homebrew on a Mac.
node wget sqlite3 bunzip2 tippecanoeThere are also some node dependencies, so dont for get to
npm install
The script generate_tiles.sh will take care of downloading and processing the data into an .mbtiles file. The general steps are
- Download whosonfirst constituency data
- Extract the GeoJSON using
sqlite3 - Post-process the data with
./generate_layers.jsto add tippecanoe metadata - Run
tippecanoeon the GeoJSON to output an.mbtilesfile
Once done, the generated .mbtiles file will be in the ./tiles folder. You can find the additional downloaded and processed files in ./data.
Once the MBTiles have been generated, you can start the node server to server:
node server.js
Going to http://localhost:3030 should serve the index.html file, that will render the tileset using Mapbox GL
There is also a view with a Mapbox basemap at http://localhost:3030/basemap. You will need to add the MAPBOX_ACCESS_TOKEN variable to a .env file (env variables are being loaded via dotenv).
Thanks to Geocode Earth for graciously building and hosing the whosonfirst data
Most of the server-related code was inspired by Tileserver GL

