Name

ST_AsGeobuf — Return a Geobuf representation of a set of rows.

Synopsis

bytea ST_AsGeobuf(text geom_name, anyelement row);

Description

Return a Geobuf representation (https://github.com/mapbox/geobuf) of a set of rows corresponding to a FeatureCollection. Every input geometry is analyzed to determine maximum precision for optimal storage. Note that Geobuf in its current form cannot be streamed so the full output will be assembled in memory.

geom_name is the name of the geometry column in the row data.

row row data with at least a geometry column.

Availability: 2.4.0

Examples

encode(ST_AsGeobuf('geom', q), 'base64')
    FROM (SELECT ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))') as geom) AS q;
 st_asgeobuf
----------------------------------
 GAAiEAoOCgwIBBoIAAAAAgIAAAE=