Introduction To Vector Tiles
Vector tiles provide performant rendering of map data for large vector feature datasets across large regions and zoom levels. Here’s why, and when, they should be used:- Vector tiles are designed for use in web maps, mobile apps, and desktop GIS software.
- WherobotsDB makes it easy and affordable to generate vector tiles at a planetary scale.
- By rendering vector tiles directly, the interactive map experience is more responsive and scalable for large datasets than rendering feature formats (e.g., GeoJSON) directly and allows developers to customize the display, which is otherwise impossible with raster tiles.
How To Generate Vector Tiles
Start a Sedona Session
As always, begin by starting a Sedona contextLoad Feature Data
Create a Spatial DataFrame with a geometry column and a layer column. The geometry column contains the features to render in the map. The layer column is a string that describes the grouping the feature should be in. Records within the same layer can be styled together, independently of other layers. In this case example features that represent buildings are in the buildings layer and those representing roads are in the roads layer. The first cell that follows gives some variable to control where we generate tiles for. The default is a small town in Washington: Issaquah.Create Tiles as a PMTiles Archive
Once we have the Spatial DataFrame ready for tile generation, we can use thevtiles.generate_pmtiles method to create a PMTiles archive. PMTiles is a performant, simple, and optimized format for storing vector tiles.
Wherobots will automatically handle the details for you. However, if you need more control, a GenerationConfig object can optionally be provided as an argument to control which tiles are created and their contents. A PMTilesConfig object can optionally be provided to control the header information of the PMTiles Archive.
Visualizing Vector Tiles with leafmap
We’ve made it easy to use leafmap to visualize the vector tiles we just generated. Leafmap is a popular geospatial visualization tool for Jupyter notebooks. We offer a function that makes it easy to use leafmap. This function creates a signed URL, styles the tiles, and returns a Leafmap object. The function can be used as follows:Quick Generation of Tiles
Sometimes you want to quickly visualize a massive dataset. To achieve this goal, WherobotsDB provides a function for quickly generating, saving, and displaying tiles. When testing this function it completed 100 million features in less than 5 minutes on a Wherobots Cloud Cairo runtime. This is accomplished by limiting the features processed to 100 million and generating fewer zoom levels at a higher resolution. At high zooms, the low precision from the low maximum zoom may be evident. The Scala/Java API exposes thegetQuickConfig method which provides the same GenerationConfig. This can be passed to
the vtiles.generate or vtiles.generatePMTiles methods for the same tile generation functionality.
This feature can be used as follows:

