Name

ST_AsMVT — Return a Mapbox Vector Tile representation of a set of rows.

Synopsis

bytea ST_AsMVT(text name, int4 extent, text geom_name, anyelement row);

Description

Return a Mapbox Vector Tile representation of a set of rows corresponding to a Layer. Multiple calls can be concatenated to a tile with multiple Layers. Geometry is assumed to be in tile coordinate space and valid as per specification. Typically ST_AsMVTGeom can be used to transform geometry into tile coordinate space. Other row data will be encoded as attributes.

name is the name of the Layer

extent is the tile extent in screen space as defined by the specification. If NULL it will default to 4096.

geom_name is the name of the geometry column in the row data.

row row data with at least a geometry column.

Availability: 2.4.0

Examples

SELECT ST_AsMVT('test', 4096, 'geom', q) FROM (SELECT 1 AS c1,
    ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'),
    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
                              st_asmvt
--------------------------------------------------------------------
 \x1a330a0474657374122112020000180322190946ec3f2214453b0a092832140f091d271a1e09091e13130f1a026331220228017802

		
		

See Also

ST_AsMVTGeom