Issues
- Tracked in our central issue repository: Geo Issues
Open States Geography Processing & Server
Generate and upload map tiles for the state-level legislative district maps on openstates.org, both for state overviews and for individual legislators.
- Source: SLDL and SLDU shapefiles from the Census's TIGER/Line database
- Output: a single nationwide MBTiles vector tile set, uploaded to Mapbox for hosting
- Intermediate files are also built and retained locally, stored in the
data
directory for debugging
- Intermediate files are also built and retained locally, stored in the
Dependencies
- Python 3 and
poetry
- GDAL 2
curl
tippecanoe
unzip
Running
There are several steps, which typically need to be run in order:
- Setup Poetry:
poetry install
- Download SLD shapefiles:
poetry run ./scripts/get-shapefiles.py
- Convert to geojson with division IDs:
poetry run ./scripts/to-geojson.py
- Import into database:
poetry run ./manage.py load_divisions
- Convert to mbtiles and upload:
./scripts/make-tiles.py
The MAPBOX_ACCOUNT
name and MAPBOX_ACCESS_TOKEN
(with upload privileges) must be set as environment variables. If not, then the upload step will be skipped.
Running within Docker
Instead of setting up your local environment you can instead run using Docker. Using Docker Compose will still allow you to access all intermediate files from the processing, within your local data
directory.
Build and run with Docker Compose. Similar to running without Docker, the MAPBOX_ACCOUNT
and MAPBOX_ACCESS_TOKEN
must be set in your local environment.
docker-compose up make-tiles