All Products
Search
Document Center

PolarDB:ST_AsMVTGeom3D

Last Updated:Mar 27, 2026

Transforms a 3D geometry into the tile coordinate system required by ST_AsMVT3D.

Syntax

geometry ST_AsMVTGeom3D(
  geometry geom,
  box2d bounds,
  integer extent = 4096,
  integer buffer = 256,
  boolean clip_geom = true
);

Parameters

ParameterTypeDefaultValid valuesDescription
geomgeometryThe 3D geometry object.
boundsbox2dThe rectangular boundaries of the tile, excluding the buffer.
extentinteger4096256–8192The size of the tile in the tile coordinate system.
bufferinteger2561–4096The size of the buffer in the tile coordinate system.
clip_geombooleantrueSpecifies whether to clip the 3D geometry object at tile boundaries.

Description

ST_AsMVTGeom3D is an extension of ST_AsMVTGeom that additionally transforms the z-axis data of a 3D geometry. Use it to prepare geometries before passing them to ST_AsMVT3D.

The function requires tile boundaries in the correct spatial coordinate system so it can transform and clip geometries as needed. To generate tile boundaries, call ST_TileEnvelope.

Note This function does not support 3D polygon objects that contain interior rings.

Example

The following example transforms a 3D line geometry from WGS 84 (SRID 4326) to Web Mercator (SRID 3857), then converts it to the tile coordinate system for tile (z=1, x=0, y=0).

SELECT ST_AsText(
  ST_AsMVTGeom3D(
    ST_Transform('SRID=4326; LINESTRING(-10 -10 30, -10 -20 30)'::geometry, 3857),
    ST_TileEnvelope(1, 0, 0)
  )
) AS geom;

Output:

                                        geom
------------------------------------------------------------------------------------
 MULTILINESTRING Z ((3868.44444444444 4324.7197219642 30,3868.44444444444 4352 30))
(1 row)