Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 33.8Mb
PDF (A4) - 33.8Mb
PDF (RPM) - 31.8Mb
HTML Download (TGZ) - 8.1Mb
HTML Download (Zip) - 8.2Mb
HTML Download (RPM) - 7.0Mb
Man Pages (TGZ) - 146.0Kb
Man Pages (Zip) - 207.0Kb
Info (Gzip) - 3.1Mb
Info (Zip) - 3.1Mb


MySQL 8.0 Reference Manual  /  ...  /  Functions That Create Geometry Values from WKB Values

Pre-General Availability Draft: 2017-11-22

12.15.4 Functions That Create Geometry Values from WKB Values

These functions take as arguments a BLOB containing a Well-Known Binary (WKB) representation and, optionally, a spatial reference system identifier (SRID). They return the corresponding geometry. For a description of WKB format, see Well-Known Binary (WKB) Format.

Functions in this section detect arguments in either Cartesian or geographic spatial reference systems (SRSs), and return results appropriate to the SRS.

ST_GeomFromWKB() accepts a WKB value of any geometry type as its first argument. Other functions provide type-specific construction functions for construction of geometry values of each geometry type.

Prior to MySQL 8.0, these functions also accepted geometry objects as returned by the functions in Section 12.15.5, “MySQL-Specific Functions That Create Geometry Values”. Geometry arguments are no longer permitted and produce an error. To migrate calls from using geometry arguments to using WKB arguments, follow these guidelines:

  • Rewrite constructs such as ST_GeomFromWKB(Point(0, 0)) as Point(0, 0).

  • Rewrite constructs such as ST_GeomFromWKB(Point(0, 0), 4326) as ST_SRID(Point(0, 0), 4326) or ST_GeomFromWKB(ST_AsWKB(Point(0, 0)), 4326).

Functions in this section handle their arguments as follows:

  • If the WKB or SRID argument is NULL, the return value is NULL.

  • By default, geographic coordinates (latitude, longitude) are interpreted as in the order specified by the spatial reference system. An optional options argument may be given to override the default axis order.

    If the options argument is NULL, the return value is NULL. If the options argument is invalid, an error occurs to indicate why.

  • As of MySQL 8.0.4, if an SRID argument does not refer to a known SRS (has an unknown SRID value), an ER_SRS_NOT_FOUND error occurs. Before MySQL 8.0.4, SRID argument validity is not checked.

  • As of MySQL 8.0.4, for geographic SRS geometry arguments, if any argument has a longitude or latitude that is out of range, an error occurs:

    Ranges shown are in degrees. If an SRS uses another unit, the range uses the corresponding values in its unit. The exact range limits deviate slightly due to floating-point arithmetic.

    Before MySQL 8.0.4, longitude/latitude validity is not checked.

These functions are available for creating geometries from WKB values:


User Comments
Sign Up Login You must be logged in to post a comment.