ST_AsGeobuf

Name

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

Synopsis

bytea ST_AsGeobuf ( anyelement set row ) ;

bytea ST_AsGeobuf ( anyelement row , text geom_name ) ;

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.

row row data with at least a geometry column.

geom_name is the name of the geometry column in the row data. If NULL it will default to the first found geometry column.

Availability: 2.4.0

Examples

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