Queries a tile from a named pyramid and returns it as a Mapbox Vector Tile (MVT) binary.
Syntax
bytea ST_Tile(cstring name, cstring key);
bytea ST_Tile(cstring name, int x, int y, int z);Parameters
| Parameter | Type | Description |
|---|---|---|
name | cstring | The name of the pyramid. |
key | cstring | The tile ID in z_x_y format (e.g., 3_1_6). |
x | int | The x value in the tile ID. |
y | int | The y value in the tile ID. |
z | int | The z value in the tile ID. |
Description
ST_Tile queries a tile from a pyramid and returns it as a bytea value in MVT format. The two syntax forms are equivalent: pass the tile ID either as a z_x_y string or as three separate integers.
Tile IDs follow the z_x_y scheme, where z is the zoom level and x/y identify the tile's column and row within the grid at that zoom level. The pyramid must be built on either the EPSG:4326 (WGS 84) or EPSG:3857 (Web Mercator) coordinate system.
When using EPSG:4326, the tile grid has twice as many columns as rows at every zoom level. The zoom level starts at 1, so at z=1 the only valid tile IDs are 1_0_0 and 1_1_0.
Examples
Both calls below query the same tile from the roads pyramid and return identical output.
-- Using a key string
SELECT ST_Tile('roads', '3_1_6');-- Using separate x, y, z integers
SELECT ST_Tile('roads', 1, 6, 3);Output:
st_tile
----------
0xFFAABB8D8A6678...What's next
Create a pyramid with the pyramid creation functions before calling
ST_Tile.