Returns the Tiny Well-Known Binary (TWKB) representation of one or more geometry objects as a bytea value.
Syntax
Single geometry
bytea ST_AsTWKB(
geometry g1,
integer decimaldigitsXY,
integer decimaldigitsZ,
integer decimaldigitsM,
boolean includeSizes,
boolean includeBoundingBoxes
);Geometry array with unique IDs
bytea ST_AsTWKB(
geometry[] geometries,
bigint[] uniqueIds,
integer decimaldigitsXY,
integer decimaldigitsZ,
integer decimaldigitsM,
boolean includeSizes,
boolean includeBoundingBoxes
);Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
g1 | geometry | — | The geometry object to encode as TWKB. |
geometries | geometry[] | — | The geometry objects to encode as TWKB. |
uniqueIds | bigint[] | — | The unique identifiers of the geometry objects in geometries. |
decimaldigitsXY | integer | 0 | The number of decimal places to retain in the x and y coordinates. |
decimaldigitsZ | integer | 0 | The number of decimal places to retain in the z coordinate. |
decimaldigitsM | integer | 0 | The number of decimal places to retain in the m coordinate. |
includeSizes | boolean | false | Specifies whether to include the size of each geometry object in the output. |
includeBoundingBoxes | boolean | false | Specifies whether to include the bounding box of each geometry object in the output. |
Examples
Convert a point geometry to its TWKB representation:
SELECT ST_AsTWKB(ST_GeomFromText('POINT(116 40)', 4326));Output:
st_astwkb
------------------------
\xa1008082880b80a4e803
(1 row)该文章对您有帮助吗?