This tool is an alternative to Mapbox Studio and lets you easily create or update vector tilesets on Mapbox from your CSV files using command line. It can be especially handy if you need to:
...
MapboxUtils is distributed as a Docker image so you need to have Docker platform installed. You can get Docker here.
MapboxUtils is publicly available on Docker hub: https://hub.docker.com/r/clevermaps/mapbox-utils
...
Data requirements
- Input file needs to be either in CSV, SHP or GeoJSON format
- Geometry needs to be in WKT format in case of CSV format
- Geometry needs to be in WGS84 coordinate system
Typically if you have your geodata in Shapefile format, you can transform it with your favorite GIS tool or you can use ogr2ogr utility with following command:
...
MapboxUtils parameters
name | mandatory | example | description |
---|---|---|---|
inputfile | yes | --inputfile /workdir/countries_wkt.csv |
Path of the input CSV file with geometry | |||
pkeycolumn | yes | --pkeycolumn id | Name of the primary key column |
geomcolumn | yes in case of CSV format | --geomcolumn |
wkt |
Name of the column with WKT geometry |
. | |||
tilesetmapid | no | --tilesetmapid cleveranalytics.14j1fhp2 | Mapbox tilesetmapid. If not specified than random value is generated by Mapbox. Specify in case of updating an existing tileset. |
tilesetname | no | --tilesetname countries_wkt-02ssft | Mapbox tilesetname. If not than specified than tilesetname is generated as combination of input file name and random hash. Specify in case of updating an existing tileset or if you need your own tilesetname. |
layername | no | --layername countries_wkt | Mapbox layername. If not specified than same value as tilesetname is used. Specify in case of updating an existing tileset or if you need your own layername. |
minzoom | no | --minzoom 5 | Minimal zoom of the tileset |
maxzoom | no | --maxzoom |
10 | Maximal zoom of the tileset |
fields
--fields "id:integer;name:string"
. Maximal allowed zoom is 10. | |||
mbtiles_params | no | --mbtiles_params "drop-fraction-as-needed extend-zooms-if-still-dropping" | Parameters of MBTiles generation internally used by tippecanoe. Parameters can be found here https://github.com/mapbox/tippecanoe |
mapboxtoken | yes | --mapboxtoken abcdefgah1234 | Your Mapbox account token. Token needs to have following priviliges: TILESETS:WRITE, TILESETS:READ, TILESETS:LIST, UPLOADS:READ, UPLOADS:WRITE. Check https://docs.mapbox.com/help/how-mapbox-works/access-tokens/ for more information. |
Running MapboxUtils
Create a new tileset without specifying tilesetname or layername
Code Block |
---|
docker run -t -v /home/user/clevermaps/mapbox-utils:/workdir clevermaps/mapbox-utils:latest --inputfile /workdir/countries_wkt.csv --pkeycolumn id --geomcolumn wkt --minzoom 5 --maxzoom 1510 --fields "id:integer;name:string" --mapboxtoken abcdefgah1234 |
...
Code Block |
---|
docker run -t -v /home/user/clevermaps/mapbox-utils:/workdir clevermaps/mapbox-utils:latest --inputfile /workdir/countries_wkt.csv --pkeycolumn id --geomcolumn wkt --minzoom 5 --maxzoom 1510 --fields "id:integer;name:string" --mapboxtoken abcdefgah1234 --tilesetname countries_wkt --layername countries_wkt |
...
Code Block |
---|
docker run -t -v /home/user/clevermaps/mapbox-utils:/workdir clevermaps/mapbox-utils:latest --inputfile /workdir/countries_wkt.csv --pkeycolumn id --geomcolumn wkt --minzoom 5 --maxzoom 1510 --fields "id:integer;name:string" --mapboxtoken abcdefgah1234 --tilesetmapid cleveranalytics.14j1fhp2 --tilesetname countries_wkt-02ssft --layername countries_wkt |