MySQL tutorial: ST_ASBINARY [EN]
top of page
CerebroSQL

MySQL: 

ST_ASBINARY

ST_AsBinary(g [, options]), ST_AsWKB(g [, options])

Converts a value in internal geometry format to its WKB representation
and returns the binary result.

The function return value has geographic coordinates (latitude,
longitude) in the order specified by the spatial reference system that
applies to the geometry argument. An optional options argument may be
given to override the default axis order.

ST_AsBinary() and ST_AsWKB() handle their arguments as described in the
introduction to this section.

URL: https://dev.mysql.com/doc/refman/8.0/en/gis-format-conversion-functions.html

Example

mysql> SET @g = ST_LineFromText('LINESTRING(0 5,5 10,10 15)', 4326);
mysql> SELECT ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g)));
+-----------------------------------------+
| ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g))) |
+-----------------------------------------+
| LINESTRING(5 0,10 5,15 10) |
+-----------------------------------------+
mysql> SELECT ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=long-lat')));
+----------------------------------------------------------------+
| ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=long-lat'))) |
+----------------------------------------------------------------+
| LINESTRING(0 5,5 10,10 15) |
+----------------------------------------------------------------+
mysql> SELECT ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=lat-long')));
+----------------------------------------------------------------+
| ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=lat-long'))) |
+----------------------------------------------------------------+
| LINESTRING(5 0,10 5,15 10) |
+----------------------------------------------------------------+

bottom of page