7

I am searching for a tool to generate vector-tiles that I can then display using the Mapbox Map-View.

We currently have a postgres database with all of our data. What is the best tool to generate vector mbtile tiles? What would be awesome it a tool where we can (ideally with a GUI) define what kind of data is embedded into the tiles at which zoom level.

If we could gather the information from our postgres database would also be cool, so we can pack all the information we need into the vector tiles.

9

POSTGIS now supports outputting vector tiles as endpoint to a Query. https://postgis.net/docs/ST_AsMVT.html I honestly don't recommend this approach because currently that's just geometry and no attributes.

You can also pair POSTGIS with GeoServer and GeoWebCache to produce vector tiles but also don't recommend that.

But probably your best bet now is that GDAL 2.3 supports Writting Vector Tiles both in Folder of XYZ PBF and inside sqlite3 container mbtiles. https://www.gdal.org/drv_pg.html OGR2OGR can read from your POSTGIS database and write an mbtiles. It's slower than Tippecanoe and has less options. So you may also want to use MapBox Tippecanoe which is also free and open source. Tippecanoe can be run on Windows SubSystem for Linux (WSL) Bash Ubuntu (as well as Linux and Mac operating systems). It will require the data to be in GeoJSON (and CSV is supported) file to convert to vector tiles. Tippecanoe also has GeoJSON extensions for Zoom Level and Layer Name so you can have super granular control over the production of vector tiles. For polygons use the -pD option to not show tile boundaries and for most of the time don't do buffers. https://github.com/mapbox/tippecanoe

When producing vector tiles pay lots of attention to the attributes (Keys and Values) you are including if you are not using it as a label or popup in the map don't include it otherwise they get huge. Almost All JavaScript mapping engines now support rendering Vector Tiles some require plugins.

Go with MapBox GL JS or ESRI ArcGIS JavaScript API for the easiest integration and access to MapBox GL JSON Stylesheet support. You can serve vector tiles with just an S3 Bucket if uploading a folder of PBF's or use a tileserver with MBTILES file. I like TileServer-GL https://github.com/klokantech/tileserver-gl or TileStrata https://github.com/naturalatlas/tilestrata because you can deliver PNG tiles to clients that don't support vector tiles.
One last point is that you can use ESRI ArcGIS Pro to create vector tiles so you can connect your POSTGIS database. You need to create a Vector Tile Package VTPK and then convert that to mbtiles or extract to folder.

  • 1
    Wow... thank you so much for your response! It's a great start for me! Thanks!!!! – Georg Aug 10 '18 at 6:04
  • So if I'd go with tippecanoe, I'd go ahead and export my data from my postgis database as GeoJSON? Then use this GeoJSON as input for tippecanoe? And I'd go ahead and create one GeoJSON file per layer? Like one for roads, one for contour-lines, one for builings, ect...?!? – Georg Aug 10 '18 at 6:47
  • Pretty awesome... So I already managed to extract in my example roads around me from our Postgres DB and convert them using tippecanoe! Great! Only problem is I don't yet know if/how I can define what should be visible at what zoom level. Would be great to say f.e. up until z10 only display roads with 'highway=primary' and starting with z12 also show 'highway=secondary' and starting with z14 show all roads. Is that possible? Or how would that be achieved? Or would I have to merge several mbtiles afterwards? – Georg Aug 10 '18 at 9:34
  • 1
    Inside your geojson (not part of the geojson spec and not viewable by any other software) you add the tippecanoe Layer information and zoom level information. "type" : "Feature", "tippecanoe" : { "maxzoom" : 9, "minzoom" : 4 },{ "layer" : "streets" }, "properties" : { "FULLNAME" : "N Vasco Rd" }, You can use a Search and Replace in NotePad++ to add this information. You can use one GeoJSON that has many layers or multiple geojson each with a unique layer name. --named-layer=name:file.geojson (or -L) – Geospatial Engineer Aug 10 '18 at 14:17
1

Use Tippcanoe https://github.com/mapbox/tippecanoe.

It accepts geojson and outputs mbtiles. you can serve mbtiles using simple php script also.

You can use https://github.com/klokantech/tileserver-php this to serve mbtiles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.