All Products
Search
Document Center

ApsaraDB RDS:ST_AsMVTGeomEx

Last Updated:Mar 28, 2026

Extends ST_AsMVTGeom with a res_prec parameter that filters out geometries too small to affect the display, reducing frontend and backend processing load, network overheads, and improving visualization performance.

Syntax

GEOMETRY ST_AsMVTGeomEx(
    GEOMETRY geom,
    BOX2D bounds,
    INTEGER res_prec=1,
    INTEGER extent=4096,
    INTEGER buffer=256,
    BOOLEAN clip_geom=true
);

Parameters

ParameterTypeDefaultDescription
geomGEOMETRYThe geometry to convert.
boundsBOX2DThe rectangular boundaries of the tile, excluding the buffer.
res_precINTEGER1The filtering threshold. A geometry is filtered out if its maximum pixel span in the x-axis or y-axis is less than this value.
extentINTEGER4096The tile size in the tile coordinate system.
bufferINTEGER256The buffer size in the tile coordinate system.
clip_geomBOOLEANtrueSpecifies whether to clip geometries at tile boundaries.

Usage notes

  • Not suitable for point data visualization. Use this function for vector data of varying sizes.

  • For small tiles, setting res_prec to a large value may cause many vectors to become invisible.

Examples

The following query visualizes only vectors with a minimum span of two pixels in the x-axis or y-axis of the current tile.

WITH mvtgeom AS(SELECT ST_AsMVTGeomEx(geom, ST_Transform(ST_TileEnvelope(0,0,0),4326),2)AS geom
FROM geom_table
WHERE geom && ST_Transform(ST_TileEnvelope(0,0,0),4326))
SELECT ST_AsMVT(mvtgeom.*);