<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="gis-wkb-functions">
      </a>
      14.16.4 Functions That Create Geometry Values from WKB Values
     </h3>
    </div>
   </div>
  </div>
  <p>
   These functions take as arguments a
   <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
    <code class="literal">
     BLOB
    </code>
   </a>
   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
   <a class="xref" href="gis-data-formats.html#gis-wkb-format" title="Well-Known Binary (WKB) Format">
    Well-Known Binary (WKB) Format
   </a>
   .
  </p>
  <p>
   Functions in this section detect arguments in either Cartesian or
      geographic spatial reference systems (SRSs), and return results
      appropriate to the SRS.
  </p>
  <p>
   <a class="link" href="gis-wkb-functions.html#function_st-geomfromwkb">
    <code class="literal">
     ST_GeomFromWKB()
    </code>
   </a>
   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.
  </p>
  <p>
   Prior to MySQL 8.4, these functions also accepted
      geometry objects as returned by the functions in
   <a class="xref" href="gis-mysql-specific-functions.html" title="14.16.5 MySQL-Specific Functions That Create Geometry Values">
    Section 14.16.5, “MySQL-Specific Functions That Create Geometry Values”
   </a>
   . Geometry arguments
      are no longer permitted and produce an error. To migrate calls
      from using geometry arguments to using WKB arguments, follow these
      guidelines:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Rewrite constructs such as
      <code class="literal">
       ST_GeomFromWKB(Point(0,
          0))
      </code>
      as
      <code class="literal">
       Point(0, 0)
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Rewrite constructs such as
      <code class="literal">
       ST_GeomFromWKB(Point(0,
          0), 4326)
      </code>
      as
      <code class="literal">
       ST_SRID(Point(0, 0),
          4326)
      </code>
      or
      <code class="literal">
       ST_GeomFromWKB(ST_AsWKB(Point(0,
          0)), 4326)
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   Unless otherwise specified, functions in this section handle their
      geometry arguments as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If the WKB or SRID argument is
      <code class="literal">
       NULL
      </code>
      , the
          return value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      By default, geographic coordinates (latitude, longitude) are
          interpreted as in the order specified by the spatial reference
          system of geometry arguments. An optional
      <em class="replaceable">
       <code>
        options
       </code>
      </em>
      argument may be given to
          override the default axis order.
      <code class="option">
       options
      </code>
      consists of a list of comma-separated
      <code class="literal">
       <em class="replaceable">
        <code>
         key
        </code>
       </em>
       =
       <em class="replaceable">
        <code>
         value
        </code>
       </em>
      </code>
      .
          The only permitted
      <em class="replaceable">
       <code>
        key
       </code>
      </em>
      value is
      <code class="literal">
       axis-order
      </code>
      , with permitted values of
      <code class="literal">
       lat-long
      </code>
      ,
      <code class="literal">
       long-lat
      </code>
      and
      <code class="literal">
       srid-defined
      </code>
      (the default).
     </p>
     <p>
      If the
      <em class="replaceable">
       <code>
        options
       </code>
      </em>
      argument is
      <code class="literal">
       NULL
      </code>
      , the return value is
      <code class="literal">
       NULL
      </code>
      . If the
      <em class="replaceable">
       <code>
        options
       </code>
      </em>
      argument is invalid, an
          error occurs to indicate why.
     </p>
    </li>
    <li class="listitem">
     <p>
      If an SRID argument refers to an undefined spatial reference
          system (SRS), an
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_srs_not_found" target="_top">
       <code class="literal">
        ER_SRS_NOT_FOUND
       </code>
      </a>
      error occurs.
     </p>
    </li>
    <li class="listitem">
     <p>
      For geographic SRS geometry arguments, if any argument has a
          longitude or latitude that is out of range, an error occurs:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         If a longitude value is not in the range (−180,
              180], an
         <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_longitude_out_of_range" target="_top">
          <code class="literal">
           ER_LONGITUDE_OUT_OF_RANGE
          </code>
         </a>
         error occurs.
        </p>
       </li>
       <li class="listitem">
        <p>
         If a latitude value is not in the range [−90, 90],
              an
         <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_latitude_out_of_range" target="_top">
          <code class="literal">
           ER_LATITUDE_OUT_OF_RANGE
          </code>
         </a>
         error occurs.
        </p>
       </li>
      </ul>
     </div>
     <p>
      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.
     </p>
    </li>
   </ul>
  </div>
  <p>
   These functions are available for creating geometries from WKB
      values:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_st-geomcollfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-geomcollfromwkb">
       <code class="literal">
        ST_GeomCollFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-geomcollfromwkb">
       <code class="literal">
        ST_GeometryCollectionFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197856352">
     </a>
     <a class="indexterm" name="idm46045197855280">
     </a>
     <p>
      Constructs a
      <code class="literal">
       GeometryCollection
      </code>
      value using
          its WKB representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-geomfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-geomfromwkb">
       <code class="literal">
        ST_GeomFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-geomfromwkb">
       <code class="literal">
        ST_GeometryFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197843712">
     </a>
     <a class="indexterm" name="idm46045197842640">
     </a>
     <p>
      Constructs a geometry value of any type using its WKB
          representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-linefromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-linefromwkb">
       <code class="literal">
        ST_LineFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-linefromwkb">
       <code class="literal">
        ST_LineStringFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197831776">
     </a>
     <a class="indexterm" name="idm46045197830704">
     </a>
     <p>
      Constructs a
      <code class="literal">
       LineString
      </code>
      value using its WKB
          representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-mlinefromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-mlinefromwkb">
       <code class="literal">
        ST_MLineFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-mlinefromwkb">
       <code class="literal">
        ST_MultiLineStringFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197819024">
     </a>
     <a class="indexterm" name="idm46045197817952">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiLineString
      </code>
      value using
          its WKB representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-mpointfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-mpointfromwkb">
       <code class="literal">
        ST_MPointFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-mpointfromwkb">
       <code class="literal">
        ST_MultiPointFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197806224">
     </a>
     <a class="indexterm" name="idm46045197805152">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiPoint
      </code>
      value using its WKB
          representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-mpolyfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-mpolyfromwkb">
       <code class="literal">
        ST_MPolyFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-mpolyfromwkb">
       <code class="literal">
        ST_MultiPolygonFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197793552">
     </a>
     <a class="indexterm" name="idm46045197792480">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiPolygon
      </code>
      value using its
          WKB representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-pointfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-pointfromwkb">
       <code class="literal">
        ST_PointFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197783440">
     </a>
     <p>
      Constructs a
      <code class="literal">
       Point
      </code>
      value using its WKB
          representation and SRID.
     </p>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-pointfromwkb">
       <code class="literal">
        ST_PointFromWKB()
       </code>
      </a>
      handles its
          arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_st-polyfromwkb">
     </a>
     <p>
      <a class="link" href="gis-wkb-functions.html#function_st-polyfromwkb">
       <code class="literal">
        ST_PolyFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
      ,
      <a class="link" href="gis-wkb-functions.html#function_st-polyfromwkb">
       <code class="literal">
        ST_PolygonFromWKB(
        <em class="replaceable">
         <code>
          wkb
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          srid
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          options
         </code>
        </em>
        ]])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197770720">
     </a>
     <a class="indexterm" name="idm46045197769648">
     </a>
     <p>
      Constructs a
      <code class="literal">
       Polygon
      </code>
      value using its WKB
          representation and SRID.
     </p>
     <p>
      These functions handle their arguments as described in the
          introduction to this section.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
