ST_GEOMETRYFROMWKB
Descriptionβ
Converts a standard figure WKB (Well-known binary) to the corresponding memory geometry
Aliasβ
- ST_GEOMFROMWKB
Syntaxβ
ST_GEOMETRYFROMWKB( <wkb>)
Parametersβ
Parameters | Instructions |
---|---|
<wkb> | A binary representation of a geometry, typically generated by ST_AsBinary or other WKB-producing functions. Supported geometry types include all standard types: POINT, LINESTRING,LINE, POLYGON |
Return Valueβ
Returns the geometric object corresponding to the input WKB. Returns NULL if the input is NULL or an invalid WKB format.
Examplesβ
POINT Type Argument
select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
+------------------------------------------------------------------+
| st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
+------------------------------------------------------------------+
| POINT (24.7 56.7) |
+------------------------------------------------------------------+
select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
+--------------------------------------------------------------+
| st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
+--------------------------------------------------------------+
| POINT (24.7 56.7) |
+--------------------------------------------------------------+
LINESTRING Type Argument
select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
+------------------------------------------------------------------------------------------+
| st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
+------------------------------------------------------------------------------------------+
| LINESTRING (1 1, 2 2) |
+------------------------------------------------------------------------------------------+
POLYGON Type Argument
select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Input NULL
mysql> SELECT ST_AsText(ST_GeometryFromWKB(NULL));
+-------------------------------------+
| ST_AsText(ST_GeometryFromWKB(NULL)) |
+-------------------------------------+
| NULL |
+-------------------------------------+
valid wkb
mysql> select ST_AsText(ST_GeometryFromWKB("\x010300000001000000050000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000024400000000000000000"));
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromWKB("\x010300000001000000050000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000024400000000000000000")) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| POLYGON ((10 0, 10 10, 0 10, 0 0, 10 0)) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
invalid wkb
mysql> select ST_AsText(ST_GeometryFromWKB("\010300000001000000050000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000024400000000000000000"));
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromWKB("\010300000001000000050000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000024400000000000000000")) |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| NULL |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+