All Products
Search
Document Center

PolarDB:ST_AsMeshGeom

Last Updated:Mar 28, 2026

Converts a geomgrid geographic grid object to its meshgeom spatial representation.

Syntax

meshgeom ST_AsMeshGeom(geomgrid grid);
meshgeom[] ST_AsMeshGeom(geomgrid[] grid);

Parameters

ParameterDescription
gridThe geographic grid object to convert. Pass a geomgrid[] array to convert multiple grids in a single call.

Description

ST_AsMeshGeom returns the meshgeom-type spatial range of a geographic grid. The meshgeom type represents the 3D geometry of a grid cell as an indexed surface mesh, encoding vertex coordinates and face indices. Pass a single geomgrid to get a single meshgeom; pass a geomgrid[] array to get a meshgeom[] array.

Example

The following example generates the 3D grid cells that contain a given point using ST_As3DGrid, then converts each cell to its meshgeom representation. ST_AsText renders the result as human-readable WKT.

SELECT ST_AsText(ST_AsMeshGeom(unnest(ST_As3DGrid(
  'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry, 20))));

Output:

                                   st_astext
--------------------------------------------------------------------------------------------------------------
 MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(116.315 39.91 970.027683307417,116.315 39.9105555555556 970.027683307417,
116.315555555556 39.9105555555556 970.027683307417,116.315555555556 39.91 970.027683307417,
116.315 39.91 1023.92243561707,116.315 39.9105555555556 1023.92243561707,
116.315555555556 39.9105555555556 1023.92243561707,116.315555555556 39.91 1023.92243561707),
INDEX((0,1,2,3),(4,7,6,5),(0,4,5,1),(3,2,6,7),(0,3,7,4),(1,5,6,2)))))