All Products
Search
Document Center

ApsaraDB RDS:ST_AsMVTGeom

Last Updated:Apr 23, 2024

This function converts a geographic grid object into a geometric object in a tile coordinate system.

Syntax

geometry ST_AsMVTGeom(geomgrid grid, geometry bounds, int4 extent, int4 buffer, boolean clip_geom);
geometry ST_AsMVTGeom(h3grid grid, geometry bounds, int4 extent, int4 buffer, boolean clip_geom);

Return values

This function returns a geometric object in a coordinate system.

Parameters

Parameter

Description

grid

The geomgrid or H3 geographic grid object that you want to output to MVT.

bounds

The rectangular boundaries of the tile, excluding the buffer.

extent

The size of the tile in the tile coordinate system. Default value: 4096.

buffer

The size of the buffer in the tile coordinate system. Default value: 256.

clip_geom

Specifies whether the geometry corresponding to the grid is clipped by the tile boundary. Default value: true.

Usage notes

  • This function converts the geometry corresponding to a geographic grid object into a geometry in a tile coordinate system.

  • Unlike the ST_AsMVTGeom function whose input parameter is Geometry, the rectangular boundary type of the tile is Geometry instead of Box2D.

  • The output coordinate system is determined by the value of the bounds parameter. We recommend that you use the ST_TileEnvelope function to generate the value of the bounds parameter.

  • If you use a method other than the ST_TileEnvelope function to generate the value of the bounds parameter, specify the Spatial Reference Identifier (SRID).

Examples

select st_asmvtgeom('010200040000'::geomgrid, st_tileenvelope(0, 0, 0));

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 0103000020110F000001000000050000000000000000D8A2400000000000FC99400000000000D8A240000000000000A040000000000000A040000000000000A040000000000000A0400000000000FC99400000000000D8A2400000000000FC9940

select st_asmvtgeom('010200040000'::geomgrid, st_transform(st_tileenvelope(0, 0, 0), 4326));

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 0103000020E610000001000000050000000000000000D8A2400000000000F493400000000000D8A240000000000000A040000000000000A040000000000000A040000000000000A0400000000000F493400000000000D8A2400000000000F49340

select st_asmvtgeom('010200040000'::geomgrid, st_transform(st_tileenvelope(0, 0, 0), 4326), 1024, 128, false);

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 0103000020E610000001000000050000000000000000D882400000000000F073400000000000D8824000000000000080400000000000008040000000000000804000000000000080400000000000F073400000000000D882400000000000F07340

select st_asmvtgeom(st_h3fromlatlng(20.5, 128.2, 5), st_tileenvelope(0, 0, 0));


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 0103000020110F00000100000006000000000000000064AB400000000000449C40000000000066AB400000000000489C40000000000066AB4000000000004C9C40000000000062AB4000000000004C9C40000000000062AB400000000000489C40000000000064AB400000000000449C40

select st_asmvtgeom(st_h3fromlatlng(20.5, 128.2, 5), 'SRID=4326;POLYGON((-180 -85,-180 85, 180 85, 180 -85, -180 -85))');


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 0103000020E61000000100000007000000000000000064AB400000000000449840000000000066AB400000000000489840000000000066AB400000000000509840000000000064AB400000000000549840000000000062AB400000000000549840000000000062AB4000000000004C9840000000000064AB40000000000044984