Contact us

The following are the built-in functions for converting spatial objects either to/from their textual (WKT) representations or between different coordinate systems (planar - spherical/geodesic). They are divided into two sections:


Geometry - Geography Conversions


fn ST_TOGEOG
ST_TOGEOG(pt: point) -> geogpoint
ST_TOGEOG(ls: linestring) -> geoglinestring
ST_TOGEOG(py: polygon) -> geogpolygon
ST_TOGEOG(mpt: multipoint) -> geogmultipoint
ST_TOGEOG(mls: multilinestring) -> gmultilinestring
ST_TOGEOG(mpy: multipolygon) -> gmultipolygon

Converts geometric objects (with Mireo World-Point coordinates) to geographic objects (with WGS 84 lon/lat coordinates).

Null handling

If the argument is NULL, the function will also return NULL.

Examples

SELECT ST_TOGEOG(point '(1751392 41864680)');
  --> POINT(2.3488 48.8534)

See also


fn ST_TOGEOM
ST_TOGEOM(gpt: geogpoint) -> point
ST_TOGEOM(gls: geoglinestring) -> linestring
ST_TOGEOM(gpy: geogpolygon) -> polygon
ST_TOGEOM(gmpt: geogmultipoint) -> multipoint
ST_TOGEOM(gmls: geogmultilinestring) -> multilinestring
ST_TOGEOM(gmpy: geogmultipolygon) -> multipolygon

Converts geographic objects (with WGS 84 lon/lat coordinates) to geographic objects (with Mireo World-Point coordinates).

Null handling

If the argument is NULL, the function will also return NULL.

Examples

SELECT ST_TOGEOM(geogpoint '(2.3488 48.8534)');
  --> POINT(1751392.219591 41864680.282055)

See also


Spatial - Text (WKT) Conversions


fn ST_POINTFROMTEXT
ST_POINTFROMTEXT(wkt: text) -> point

Parses a point geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a point geometry, the function will return an error: Wrong WKT type.

Notes

As empty point objects aren't allowed, 'POINT EMPTY' is considered a malformed WKT input.

Examples

SELECT ST_POINTFROMTEXT('POINT(10 20)');
  --> POINT(10 20)

fn ST_LINEFROMTEXT
ST_LINEFROMTEXT(wkt: text) -> linestring

Parses a linestring geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a linestring geometry, the function will return an error: Wrong WKT type.

Examples

SELECT ST_LINEFROMTEXT('LINESTRING(10 10, 20 30)');
  --> LINESTRING(10 10,20 30)

fn ST_POLYGONFROMTEXT
ST_POLYGONFROMTEXT(wkt: text) -> polygon

Parses a polygon geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a polygon geometry, the function will return an error: Wrong WKT type.

If any polygon ring from the parsed polygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All polygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of a parsed polygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed polygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_POLYGONFROMTEXT('POLYGON((0 0, 10 10, 0 20, 0 0))');
  --> POLYGON((0 0,10 10,0 20,0 0))

fn ST_MPOINTFROMTEXT
ST_MPOINTFROMTEXT(wkt: text) -> multipoint

Parses a multipoint geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multipoint geometry, the function will return an error: Wrong WKT type.

Notes

As empty point objects aren't allowed, a multipoint containing an empty point is considered a malformed WKT input.

Examples

SELECT ST_MPOINTFROMTEXT('MULTIPOINT(10 10, 20 30, 40 10)');
  --> MULTIPOINT((10 10),(20 30),(40 10))

fn ST_MLINEFROMTEXT
ST_MLINEFROMTEXT(wkt: text) -> multilinestring

Parses a multilinestring geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multilinestring geometry, the function will return an error: Wrong WKT type.

Examples

SELECT ST_MLINEFROMTEXT('MULTILINESTRING((10 10, 20 30), (40 10, 15 15, 15 0))');
  --> MULTILINESTRING((10 10,20 30),(40 10,15 15,15 0))

fn ST_MPOLYFROMTEXT
ST_MPOLYFROMTEXT(wkt: text) -> multipolygon

Parses a multipolygon geometry from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multipolygon geometry, the function will return an error: Wrong WKT type.

If any polygon ring from the parsed multipolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All polygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of all polygons from the parsed multipolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed multipolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_MPOLYFROMTEXT(
    'MULTIPOLYGON(((0 0, 20 0, 20 20, 0 20, 0 0), (5 5, 10 10, 15 5, 5 5)), ((30 30, 60 30, 45 45, 30 30)))');

--> MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(5 5,10 10,15 5,5 5)),((30 30,60 30,45 45,30 30)))

fn ST_GEOGPOINTFROMTEXT
ST_GEOGPOINTFROMTEXT(wkt: text) -> geogpoint

Parses a point geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a point geography, the function will return an error: Wrong WKT type.

Notes

As empty geogpoint objects aren't allowed, 'POINT EMPTY' is considered a malformed WKT input.

Examples

SELECT ST_GEOGPOINTFROMTEXT('POINT(16.51 45.22)');
  --> POINT(16.51 45.22)

fn ST_GEOGLINEFROMTEXT
ST_GEOGLINEFROMTEXT(wkt: text) -> geoglinestring

Parses a linestring geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a linestring geography, the function will return an error: Wrong WKT type.

Examples

SELECT ST_GEOGLINEFROMTEXT('LINESTRING(10.1 10.1, 50.5 75.2, 80.8 25.3)');
  --> LINESTRING(10.1 10.1,50.5 75.2,80.8 25.3)

fn ST_GEOGPOLYGONFROMTEXT
ST_GEOGPOLYGONFROMTEXT(wkt: text) -> geogpolygon

Parses a polygon geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a polygon geography, the function will return an error: Wrong WKT type.

If any polygon ring from the parsed geogpolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All geogpolygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of a parsed geogpolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed geogpolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_GEOGPOLYGONFROMTEXT(
    'POLYGON((0.0 0.0, 20.1 0.0, 20.1 20.1, 0.0 20.1, 0.0 0.0), (5.3 5.4, 10.2 10.7, 15.7 5.4, 5.3 5.4))');

--> POLYGON((0 0,20.1 0,20.1 20.1,0 20.1,0 0),(5.3 5.4,10.2 10.7,15.7 5.4,5.3 5.4))

fn ST_GEOGMPOINTFROMTEXT
ST_GEOGMPOINTFROMTEXT(wkt: text) -> geogmultipoint

Parses a multipoint geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multipoint geography, the function will return an error: Wrong WKT type.

Notes

As empty geogpoint objects aren't allowed, a geogmultipoint containing an empty geogpoint is considered a malformed WKT input.

Examples

SELECT ST_GEOGMPOINTFROMTEXT('MULTIPOINT(10.1 20.5, 35.2 50.0)');
  --> MULTIPOINT((10.1 20.5),(35.2 50))

fn ST_GEOGMLINEFROMTEXT
ST_GEOGMLINEFROMTEXT(wkt: text) -> geogmultilinestring

Parses a multilinestring geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multilinestring geography, the function will return an error: Wrong WKT type.

Examples

SELECT ST_GEOGMLINEFROMTEXT(
    'MULTILINESTRING((10.1 10.1, 50.5 75.2, 80.8 25.3), (100.5 98.2, 105.4 110.7))');

--> MULTILINESTRING((10.1 10.1,50.5 75.2,80.8 25.3),(100.5 98.2,105.4 110.7))

fn ST_GEOGMPOLYFROMTEXT
ST_GEOGMPOLYFROMTEXT(wkt: text) -> geogmultipolygon

Parses a multipolygon geography from its WKT (Well-Known Text) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKT string, the function will return an error: Malformed WKT input.

If the given WKT doesn't represent a multipolygon geography, the function will return an error: Wrong WKT type.

If any polygon ring from the parsed geogmultipolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All geogpolygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of all polygons from the parsed geogmultipolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed geogmultipolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_GEOGMPOLYFROMTEXT(
    'MULTIPOLYGON(((0.0 0.0, 20.1 0.0, 20.1 20.1, 0.0 20.1, 0.0 0.0),'
    ' (5.3 5.4, 10.2 10.7, 15.7 5.4, 5.3 5.4)),'
    ' ((50.5 40.5, 50.5 60.5, 45.5 55.5, 50.5 40.5)))');

--> MULTIPOLYGON(((0 0,20.1 0,20.1 20.1,0 20.1,0 0),(5.3 5.4,10.2 10.7,15.7 5.4,5.3 5.4)),((50.5 40.5,50.5 60.5,45.5 55.5,50.5 40.5)))

fn ST_ASTEXT
ST_ASTEXT(g: anygeometry) -> text
ST_ASTEXT(g: anygeography) -> text

Returns the Well-Known Text (WKT) representation of a given geometric/geographic object.

Null handling

If the argument is NULL, the function will also return NULL.

Examples

SELECT ST_ASTEXT(point '(10 20)');
  --> 'POINT(10 20)'
SELECT ST_ASTEXT(geoglinestring '(10.5 20.2, 30.0 25.4, 55.7 70.1)');
  --> 'LINESTRING(10.5 20.2,30 25.4,55.7 70.1)'

See also


Spatial - Binary (WKB) Conversions

fn ST_POINTFROMWKB
ST_POINTFROMWKB(wkb: binary) -> point

Parses a point geometry from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a point geometry, the function will return an error: Wrong WKB type.

Examples

SELECT ST_PointFromWKB(x'010100000000000000000024400000000000003440');
  --> POINT(10 20)

fn ST_LINEFROMWKB
ST_LINEFROMWKB(wkb: binary) -> linestring

Parses a linestring geometry from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a linestring geometry, the function will return an error: Wrong WKB type.

Examples

SELECT ST_LineFromWKB(
   x'01020000000200000000000000000000'
    '00000000000000000000000000000024'
    '400000000000003440');

--> LINESTRING(0 0,10 20)

fn ST_POLYGONFROMWKB
ST_POLYGONFROMWKB(wkb: binary) -> polygon

Parses a polygon geometry from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a polygon geometry, the function will return an error: Wrong WKB type.

If any polygon ring from the parsed polygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All polygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of a parsed polygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed polygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_PolygonFromWKB(
   x'01030000000100000004000000000000'
    '00000000000000000000000000000000'
    '00000034400000000000000000000000'
    '00000024400000000000002440000000'
    '00000000000000000000000000');

--> POLYGON((0 0,20 0,10 10,0 0))

fn ST_MPOINTFROMWKB
ST_MPOINTFROMWKB(wkb: binary) -> multipoint

Parses a multipoint geometry from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multipoint geometry, the function will return an error: Wrong WKB type.

Examples

SELECT ST_MPointFromWKB(
   x'01040000000300000001010000000000'
    '00000000244000000000000034400101'
    '00000000000000000044400000000000'
    '002e4001010000000000000000004040'
    '00000000000028c0');

--> MULTIPOINT((10 20),(40 15),(32 -12))

fn ST_MLINEFROMWKB
ST_MLINEFROMWKB(wkb: binary) -> multilinestring

Parses a multilinestring geometry from its WKB (Well-Known WKB) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multilinestring geometry, the function will return an error: Wrong WKB type.

Examples

SELECT ST_MLineFromWKB(
   x'01050000000200000001020000000200'
    '00000000000000002440000000000000'
    '34400000000000004440000000000000'
    '2e400102000000020000000000000000'
    '00000000000000000000000000000000'
    '00404000000000000028c0');

--> MULTILINESTRING((10 20,40 15),(0 0,32 -12))

fn ST_MPOLYFROMWKB
ST_MPOLYFROMWKB(wkb: binary) -> multipolygon

Parses a multipolygon geometry from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB string, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multipolygon geometry, the function will return an error: Wrong WKB type.

If any polygon ring from the parsed multipolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All polygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of all polygons from the parsed multipolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed multipolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_MPolyFromWKB(
   x'01060000000200000001030000000200'
    '00000500000000000000000000000000'
    '00000000000000000000000034400000'
    '00000000000000000000000034400000'
    '00000000344000000000000000000000'
    '00000000344000000000000000000000'
    '00000000000004000000000000000000'
    '14400000000000001440000000000000'
    '24400000000000002440000000000000'
    '2e400000000000001440000000000000'
    '14400000000000001440010300000001'
    '000000040000000000000000003e4000'
    '00000000003e400000000000004e4000'
    '00000000003e40000000000080464000'
    '000000008046400000000000003e4000'
    '00000000003e40');

--> MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(5 5,10 10,15 5,5 5)),((30 30,60 30,45 45,30 30)))

fn ST_GEOGPOINTFROMWKB
ST_GEOGPOINTFROMWKB(wkb: binary) -> geogpoint

Parses a point geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a point geography, the function will return an error: Wrong WKB type.

Examples

SELECT ST_GeogPointFromWKB(x'0101000000c3f5285c8f8230405c8fc2f5289c4640');
  --> POINT(16.51 45.22)

fn ST_GEOGLINEFROMWKB
ST_GEOGLINEFROMWKB(wkb: binary) -> geoglinestring

Parses a linestring geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a linestring geography, the function will return an error: Wrong WKB type.

Examples

SELECT ST_GeogLineFromWKB(
   x'01020000000300000033333333333324'
    '40333333333333244000000000004049'
    '40cdcccccccccc524033333333333354'
    '40cdcccccccc4c3940');

--> LINESTRING(10.1 10.1,50.5 75.2,80.8 25.3)

fn ST_GEOGPOLYGONFROMWKB
ST_GEOGPOLYGONFROMWKB(wkb: binary) -> geogpolygon

Parses a polygon geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a polygon geography, the function will return an error: Wrong WKB type.

If any polygon ring from the parsed geogpolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All geogpolygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of a parsed geogpolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed geogpolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_GeogPolygonFromWKB(
   x'01030000000200000005000000000000'
    '000000000000000000000000009a9999'
    '999919344000000000000000009a9999'
    '99991934409a99999999193440000000'
    '00000000009a99999999193440000000'
    '00000000000000000000000000040000'
    '0033333333333315409a999999999915'
    '40666666666666244066666666666625'
    '406666666666662f409a999999999915'
    '4033333333333315409a999999999915'
    '40');

--> POLYGON((0 0,20.1 0,20.1 20.1,0 20.1,0 0),(5.3 5.4,10.2 10.7,15.7 5.4,5.3 5.4))

fn ST_GEOGMPOINTFROMWKB
ST_GEOGMPOINTFROMWKB(wkb: binary) -> geogmultipoint

Parses a multipoint geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multipoint geography, the function will return an error: Wrong WKB type.

Examples

SELECT ST_GeogMPointFromWKB(
   x'01040000000200000001010000003333'
    '33333333244000000000008034400101'
    '0000009a999999999941400000000000'
    '004940');

--> MULTIPOINT((10.1 20.5),(35.2 50))

fn ST_GEOGMLINEFROMWKB
ST_GEOGMLINEFROMWKB(wkb: binary) -> geogmultilinestring

Parses a multilinestring geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multilinestring geography, the function will return an error: Wrong WKB type.

Examples

SELECT ST_GeogMLineFromWKB(
    x'01050000000200000001020000000300'
    '00003333333333332440333333333333'
    '24400000000000404940cdcccccccccc'
    '52403333333333335440cdcccccccc4c'
    '39400102000000020000000000000000'
    '205940cdcccccccc8c58409a99999999'
    '595a40cdccccccccac5b40');

--> MULTILINESTRING((10.1 10.1,50.5 75.2,80.8 25.3),(100.5 98.2,105.4 110.7))

fn ST_GEOGMPOLYFROMWKB
ST_GEOGMPOLYFROMWKB(wkb: binary) -> geogmultipolygon

Parses a multipolygon geography from its WKB (Well-Known Binary) representation.

Null handling

If the argument is NULL, the function will also return NULL.

Error handling

If the given argument is not a valid WKB byte sequence, the function will return an error: Malformed WKB input.

If the given WKB doesn't represent a multipolygon geography, the function will return an error: Wrong WKB type.

If any polygon ring from the parsed geogmultipolygon isn't closed or contains fewer than 4 points, the function will return an error: Invalid polygon ring.

Notes

All geogpolygon objects assume a counter-clockwise orientation of its outer ring and clockwise orientation for its inner rings. If needed, the rings of all polygons from the parsed geogmultipolygon will be automatically reversed to match the expected orientation.

This function will not perform a full check for whether the parsed geogmultipolygon is valid (see ST_ISVALID for the definition of validity), because that check is computationally expensive. But this can be checked manually if needed using the ST_ISVALID function.

Examples

SELECT ST_GeogMPolyFromWKB(
   x'01060000000200000001030000000200'
    '00000500000000000000000000000000'
    '0000000000009a999999991934400000'
    '0000000000009a999999991934409a99'
    '99999919344000000000000000009a99'
    '99999919344000000000000000000000'
    '00000000000004000000333333333333'
    '15409a99999999991540666666666666'
    '24406666666666662540666666666666'
    '2f409a99999999991540333333333333'
    '15409a99999999991540010300000001'
    '00000004000000000000000040494000'
    '00000000404440000000000040494000'
    '00000000404e400000000000c0464000'
    '00000000c04b40000000000040494000'
    '00000000404440');

--> MULTIPOLYGON(((0 0,20.1 0,20.1 20.1,0 20.1,0 0),(5.3 5.4,10.2 10.7,15.7 5.4,5.3 5.4)),((50.5 40.5,50.5 60.5,45.5 55.5,50.5 40.5)))

fn ST_ASBINARY
ST_ASBINARY(g: anygeometry) -> binary
ST_ASBINARY(g: anygeography) -> binary

Returns the Well-Known Binary (WKB) representation of a given geometric/geographic object.

Null handling

If the argument is NULL, the function will also return NULL.

Examples

SELECT ST_ASBINARY(point '(10 20)');
  --> x'010100000000000000000024400000000000003440'
SELECT ST_ASBINARY(geoglinestring '(10.5 20.2, 30.0 25.4, 55.7 70.1)');
  --> x'010200000003000000000000000000254033333333333334400000000000003e4066666666666639409a99999999d94b406666666666865140'

See also