Documentation Home
MySQL 9.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.2Mb
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.4 Reference Manual  / ...  / Functions and Operators  / Spatial Analysis Functions  /  Functions That Create Geometry Values from WKB Values

14.16.4 Functions That Create Geometry Values from WKB Values

These functions take as arguments aBLOB 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, seeWell-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 9.4, these functions also accepted geometry objects as returned by the functions inSection 14.16.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 asST_GeomFromWKB(Point(0, 0)) asPoint(0, 0).

  • Rewrite constructs such asST_GeomFromWKB(Point(0, 0), 4326) asST_SRID(Point(0, 0), 4326) orST_GeomFromWKB(ST_AsWKB(Point(0, 0)), 4326).

Unless otherwise specified, functions in this section handle their geometry arguments as follows:

  • If the WKB or SRID argument isNULL, the return value isNULL.

  • By default, geographic coordinates (latitude, longitude) are interpreted as in the order specified by the spatial reference system of geometry arguments. An optionaloptions argument may be given to override the default axis order.options consists of a list of comma-separatedkey=value. The only permittedkey value isaxis-order, with permitted values oflat-long,long-lat andsrid-defined (the default).

    If theoptions argument isNULL, the return value isNULL. If theoptions argument is invalid, an error occurs to indicate why.

  • If an SRID argument refers to an undefined spatial reference system (SRS), anER_SRS_NOT_FOUND error occurs.

  • 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.

These functions are available for creating geometries from WKB values: