-
Notifications
You must be signed in to change notification settings - Fork 6
Mapbox and Tippecanoe Tutorial
Lauren Johnston edited this page May 9, 2020
·
1 revision
- Find your data ! Census blocks and a lot of other shapefiles are available from the census website at https://www.census.gov/cgi-bin/geo/shapefiles/index.php and the specific population data is included in these files ftp://ftp2.census.gov/geo/tiger/TIGER2010BLKPOPHU/
- Install tippecanoe (https://github.com/mapbox/tippecanoe)
# on MacOS
brew install tippecanoe
# on Ubuntu
git clone https://github.com/mapbox/tippecanoe.git
cd tippecanoe
make -j
make install
- Get the file, unzip, convert to geojson (might have to install GDAL for ogr2ogr,
brew install gdal
)
curl -L -O {URL}/{file-name}.zip
unzip {file-name}.zip
ogr2ogr -f GeoJSON {file-name}.geojson {file-name}.shp
- Convert to mbtiles (much smaller!):
tippecanoe -zg -o {file-name}.mbtiles --drop-densest-as-needed --extend-zooms-if-still-dropping {file-name}.geojson
- Install mapbox cli:
pip install mapboxcli
- Export mapbox token (ask me if you need it, different from mapbox key):
export MAPBOX_ACCESS_TOKEN={TOKEN}
- upload the file:
mapbox upload representable-team.{name} {file-name}.geojson
- now you can edit the javascript
map.addSource("source-name", {
type: "vector",
url: "mapbox://representable-team.{name}"
});
Make sure when you do map.addLayer()
, you add "source": "{source-name}"
and "source-layer": "{file-name}"
! you are done