ST_AsGeobuf

更新时间:
复制 MD 格式

ST_AsGeobuf converts a set of rows into a Geobuf binary representation. Use this function to export spatial data from PolarDB for PostgreSQL into Geobuf for downstream web mapping pipelines.

Syntax

bytea ST_AsGeobuf(anyelement set row);
bytea ST_AsGeobuf(anyelement row, text geomName);

Parameters

ParameterDescription
rowThe rows to encode. Each row must contain at least one geometry column.
geomNameThe name of the geometry column to use. If NULL, the function uses the first geometry column found.

Usage notes

Geobuf output cannot be streamed — the full result must be available before being returned. For large spatial datasets, make sure your session has enough memory available.

Examples

Encode a point with the single-argument syntax

SELECT ST_AsGeobuf(q)
FROM (SELECT ST_GeomFromText('POINT(116 40)', 4326)) AS q;

Output:

           st_asgeobuf
----------------------------------
 \x1800220b0a090a0708001a03e80150
(1 row)