ST_AsMVT — Return a Mapbox Vector Tile representation of a set of rows.
bytea ST_AsMVT(anyelement set row
bytea ST_AsMVT(anyelement row, text name
bytea ST_AsMVT(anyelement row, text name, integer extent
bytea ST_AsMVT(anyelement row, text name, integer extent, text geom_name
bytea ST_AsMVT(anyelement row, text name, integer extent, text geom_name, text feature_id_name
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.
The Mapbox Vector Tile format can store features with a different set of attributes per feature. To make use of this feature supply a JSONB column in the row data containing Json objects one level deep. The keys and values in the object will be parsed into feature attributes.
Do not call with a
row row data with at least a geometry column.
name is the name of the Layer. If NULL it will use the string "default".
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. If NULL it will default to the first found geometry column.
feature_id_name is the name of the Feature ID column in the row data. If NULL or negative the Feature ID is not set. The first column matching name and valid type (smallint, integer, bigint) will be used as Feature ID, and any subsequent column will be added as a property. JSON properties are not supported.
Enhanced: 3.0 - added support for Feature ID.
Enhanced: 2.5.0 - added support parallel query.
SELECT ST_AsMVT(q, 'test', 4096, 'geom') 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 -------------------------------------------------------------------- \x1a320a0474657374121d12020000180322150946ec3f1a14453b0a09280f091413121e09091e0f1a026331220228012880207802