Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This tool is an alternative to Mapbox Studio and lets you easily create or update vector tilesets on Mapbox from your CSV, SHP or GeoJSON files using command line. It can be especially handy if you need to:

  • periodically update some vector tileset (e.g. every day updates) using some script

  • fine tune zoom levels or other parameters of vector tiles

  • overcome Mapbox Studio upload limits

Under the hood the tool is using Mapbox Python API, ogr2ogr and tippecanoe utilites. Just pass your geofile, specify some parameters and you are done. 

Installation

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

Use following command to get the image:

Code Block
docker pull clevermaps/mapbox-utils:latest

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

MapboxUtils parameters

...

name

...

mandatory

...

example

...

description

...

inputfile

...

yes

...

Code Block
--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

...

Code Block
--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

...

Code Block
--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

...

Code Block
--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

...

Code Block
--minzoom 5

...

Minimal zoom of the tileset

...

maxzoom

...

no

...

Code Block
--maxzoom 10

...

Maximal zoom of the tileset. Maximal allowed zoom is 10. 

...

mbtiles_params

...

no

...

Code Block
--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

...

Code Block
--mapboxtoken abcdefgah1234

...

Panel
panelIconId1f389
panelIcon:tada:
panelIconText🎉
bgColor#E3FCEF

The content you are trying to reach has been moved here: https://docs.

...

clevermaps.

...

io/

...

docs/

...

Running MapboxUtils

Create a new tileset from CSV file

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 10 --mapboxtoken abcdefgah1234

Create a new tileset from SHP file

Code Block
docker run -t -v /home/user/clevermaps/mapbox-utils:/workdir clevermaps/mapbox-utils:latest --inputfile /workdir/countries.shp --pkeycolumn id --minzoom 5 --maxzoom 10 --mapboxtoken abcdefgah1234

Update existing tileset

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 10 --mapboxtoken abcdefgah1234 --tilesetmapid cleveranalytics.14j1fhp2 --tilesetname countries_wkt-02ssft

mapboxutils-docker

We are proud to announce that we have launched a new documentation.

Please update your saved links and bookmarks to follow a new address docs.clevermaps.io.