<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="gis-data-formats">
      </a>
      13.4.3 Supported Spatial Data Formats
     </h3>
    </div>
   </div>
  </div>
  <p>
   Two standard spatial data formats are used to represent geometry
        objects in queries:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Well-Known Text (WKT) format
     </p>
    </li>
    <li class="listitem">
     <p>
      Well-Known Binary (WKB) format
     </p>
    </li>
   </ul>
  </div>
  <p>
   Internally, MySQL stores geometry values in a format that is not
        identical to either WKT or WKB format. (Internal format is like
        WKB but with an initial 4 bytes to indicate the SRID.)
  </p>
  <p>
   There are functions available to convert between different data
        formats; see
   <a class="xref" href="gis-format-conversion-functions.html" title="14.16.6 Geometry Format Conversion Functions">
    Section 14.16.6, “Geometry Format Conversion Functions”
   </a>
   .
  </p>
  <p>
   The following sections describe the spatial data formats MySQL
        uses:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="gis-data-formats.html#gis-wkt-format" title="Well-Known Text (WKT) Format">
       Well-Known Text (WKT) Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="gis-data-formats.html#gis-wkb-format" title="Well-Known Binary (WKB) Format">
       Well-Known Binary (WKB) Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="gis-data-formats.html#gis-internal-format" title="Internal Geometry Storage Format">
       Internal Geometry Storage Format
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="gis-wkt-format">
       </a>
       Well-Known Text (WKT) Format
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045211804688">
   </a>
   <a class="indexterm" name="idm46045211803232">
   </a>
   <a class="indexterm" name="idm46045211801744">
   </a>
   <p>
    The Well-Known Text (WKT) representation of geometry values is
          designed for exchanging geometry data in ASCII form. The
          OpenGIS specification provides a Backus-Naur grammar that
          specifies the formal production rules for writing WKT values
          (see
    <a class="xref" href="spatial-types.html" title="13.4 Spatial Data Types">
     Section 13.4, “Spatial Data Types”
    </a>
    ).
   </p>
   <p>
    Examples of WKT representations of geometry objects:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       A
       <code class="literal">
        Point
       </code>
       :
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa91433989"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">POINT<span class="token punctuation">(</span>15 20<span class="token punctuation">)</span></code></pre>
      </div>
      <p>
       The point coordinates are specified with no separating
              comma. This differs from the syntax for the SQL
       <a class="link" href="gis-mysql-specific-functions.html#function_point">
        <code class="literal">
         Point()
        </code>
       </a>
       function, which
              requires a comma between the coordinates. Take care to use
              the syntax appropriate to the context of a given spatial
              operation. For example, the following statements both use
       <a class="link" href="gis-point-property-functions.html#function_st-x">
        <code class="literal">
         ST_X()
        </code>
       </a>
       to extract the
              X-coordinate from a
       <code class="literal">
        Point
       </code>
       object. The
              first produces the object directly using the
       <a class="link" href="gis-mysql-specific-functions.html#function_point">
        <code class="literal">
         Point()
        </code>
       </a>
       function. The
              second uses a WKT representation converted to a
       <code class="literal">
        Point
       </code>
       with
       <a class="link" href="gis-wkt-functions.html#function_st-geomfromtext">
        <code class="literal">
         ST_GeomFromText()
        </code>
       </a>
       .
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95943409"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ST_X</span><span class="token punctuation">(</span><span class="token function">Point</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_X(POINT(15, 20)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                  15 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ST_X</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POINT(15 20)'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_X(ST_GeomFromText('POINT(15 20)')) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                                    15 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        LineString
       </code>
       with four points:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa74879070"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">LINESTRING<span class="token punctuation">(</span>0 0<span class="token punctuation">,</span> 10 10<span class="token punctuation">,</span> 20 25<span class="token punctuation">,</span> 50 60<span class="token punctuation">)</span></code></pre>
      </div>
      <p>
       The point coordinate pairs are separated by commas.
      </p>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        Polygon
       </code>
       with one exterior ring and
              one interior ring:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa81450685"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">POLYGON<span class="token punctuation">(</span><span class="token punctuation">(</span>0 0<span class="token punctuation">,</span>10 0<span class="token punctuation">,</span>10 10<span class="token punctuation">,</span>0 10<span class="token punctuation">,</span>0 0<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span>5 5<span class="token punctuation">,</span>7 5<span class="token punctuation">,</span>7 7<span class="token punctuation">,</span>5 7<span class="token punctuation">,</span> 5 5<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        MultiPoint
       </code>
       with three
       <code class="literal">
        Point
       </code>
       values:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa88993890"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">MULTIPOINT<span class="token punctuation">(</span>0 0<span class="token punctuation">,</span> 20 20<span class="token punctuation">,</span> 60 60<span class="token punctuation">)</span></code></pre>
      </div>
      <p>
       Spatial functions such as
       <a class="link" href="gis-wkt-functions.html#function_st-mpointfromtext">
        <code class="literal">
         ST_MPointFromText()
        </code>
       </a>
       and
       <a class="link" href="gis-wkt-functions.html#function_st-geomfromtext">
        <code class="literal">
         ST_GeomFromText()
        </code>
       </a>
       that
              accept WKT-format representations of
       <code class="literal">
        MultiPoint
       </code>
       values permit individual
              points within values to be surrounded by parentheses. For
              example, both of the following function calls are valid:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30257756"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token function">ST_MPointFromText</span><span class="token punctuation">(</span><span class="token string">'MULTIPOINT (1 1, 2 2, 3 3)'</span><span class="token punctuation">)</span>
<span class="token function">ST_MPointFromText</span><span class="token punctuation">(</span><span class="token string">'MULTIPOINT ((1 1), (2 2), (3 3))'</span><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        MultiLineString
       </code>
       with two
       <code class="literal">
        LineString
       </code>
       values:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2995786"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">MULTILINESTRING<span class="token punctuation">(</span><span class="token punctuation">(</span>10 10<span class="token punctuation">,</span> 20 20<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>15 15<span class="token punctuation">,</span> 30 15<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        MultiPolygon
       </code>
       with two
       <code class="literal">
        Polygon
       </code>
       values:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa49918059"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">MULTIPOLYGON<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">(</span>0 0<span class="token punctuation">,</span>10 0<span class="token punctuation">,</span>10 10<span class="token punctuation">,</span>0 10<span class="token punctuation">,</span>0 0<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">(</span>5 5<span class="token punctuation">,</span>7 5<span class="token punctuation">,</span>7 7<span class="token punctuation">,</span>5 7<span class="token punctuation">,</span> 5 5<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        GeometryCollection
       </code>
       consisting of two
       <code class="literal">
        Point
       </code>
       values and one
       <code class="literal">
        LineString
       </code>
       :
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa44434513"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">GEOMETRYCOLLECTION<span class="token punctuation">(</span>POINT<span class="token punctuation">(</span>10 10<span class="token punctuation">)</span><span class="token punctuation">,</span> POINT<span class="token punctuation">(</span>30 30<span class="token punctuation">)</span><span class="token punctuation">,</span> LINESTRING<span class="token punctuation">(</span>15 15<span class="token punctuation">,</span> 20 20<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="gis-wkb-format">
       </a>
       Well-Known Binary (WKB) Format
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045211756336">
   </a>
   <a class="indexterm" name="idm46045211754880">
   </a>
   <a class="indexterm" name="idm46045211753376">
   </a>
   <p>
    The Well-Known Binary (WKB) representation of geometric values
          is used for exchanging geometry data as binary streams
          represented by
    <a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
     <code class="literal">
      BLOB
     </code>
    </a>
    values
          containing geometric WKB information. This format is defined
          by the OpenGIS specification (see
    <a class="xref" href="spatial-types.html" title="13.4 Spatial Data Types">
     Section 13.4, “Spatial Data Types”
    </a>
    ). It is also defined in the
          ISO
    <em class="citetitle">
     SQL/MM Part 3: Spatial
    </em>
    standard.
   </p>
   <p>
    WKB uses 1-byte unsigned integers, 4-byte unsigned integers,
          and 8-byte double-precision numbers (IEEE 754 format). A byte
          is eight bits.
   </p>
   <p>
    For example, a WKB value that corresponds to
    <code class="literal">
     POINT(1
          -1)
    </code>
    consists of this sequence of 21 bytes, each
          represented by two hexadecimal digits:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa77405367"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">0101000000000000000000F03F000000000000F0BF</code></pre>
   </div>
   <p>
    The sequence consists of the components shown in the following
          table.
   </p>
   <div class="table">
    <a name="wkb-components-example-table">
    </a>
    <p class="title">
     <b>
      Table 13.2 WKB Components Example
     </b>
    </p>
    <div class="table-contents">
     <table summary="Example showing component in WKB values.">
      <colgroup>
       <col style="width: 30%"/>
       <col style="width: 30%"/>
       <col style="width: 40%"/>
      </colgroup>
      <thead>
       <tr>
        <th scope="col">
         Component
        </th>
        <th scope="col">
         Size
        </th>
        <th scope="col">
         Value
        </th>
       </tr>
      </thead>
      <tbody>
       <tr>
        <th scope="row">
         Byte order
        </th>
        <td>
         1 byte
        </td>
        <td>
         <code class="literal">
          01
         </code>
        </td>
       </tr>
       <tr>
        <th scope="row">
         WKB type
        </th>
        <td>
         4 bytes
        </td>
        <td>
         <code class="literal">
          01000000
         </code>
        </td>
       </tr>
       <tr>
        <th scope="row">
         X coordinate
        </th>
        <td>
         8 bytes
        </td>
        <td>
         <code class="literal">
          000000000000F03F
         </code>
        </td>
       </tr>
       <tr>
        <th scope="row">
         Y coordinate
        </th>
        <td>
         8 bytes
        </td>
        <td>
         <code class="literal">
          000000000000F0BF
         </code>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
   </div>
   <br class="table-break"/>
   <p>
    Component representation is as follows:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The byte order indicator is either 1 or 0 to signify
              little-endian or big-endian storage. The little-endian and
              big-endian byte orders are also known as Network Data
              Representation (NDR) and External Data Representation
              (XDR), respectively.
      </p>
     </li>
     <li class="listitem">
      <p>
       The WKB type is a code that indicates the geometry type.
              MySQL uses values from 1 through 7 to indicate
       <code class="literal">
        Point
       </code>
       ,
       <code class="literal">
        LineString
       </code>
       ,
       <code class="literal">
        Polygon
       </code>
       ,
       <code class="literal">
        MultiPoint
       </code>
       ,
       <code class="literal">
        MultiLineString
       </code>
       ,
       <code class="literal">
        MultiPolygon
       </code>
       , and
       <code class="literal">
        GeometryCollection
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       A
       <code class="literal">
        Point
       </code>
       value has X and Y coordinates,
              each represented as a double-precision value.
      </p>
     </li>
    </ul>
   </div>
   <p>
    WKB values for more complex geometry values have more complex
          data structures, as detailed in the OpenGIS specification.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="gis-internal-format">
       </a>
       Internal Geometry Storage Format
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045211710928">
   </a>
   <a class="indexterm" name="idm46045211709472">
   </a>
   <p>
    MySQL stores geometry values using 4 bytes to indicate the
          SRID followed by the WKB representation of the value. 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>
    For the WKB part, these MySQL-specific considerations apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The byte-order indicator byte is 1 because MySQL stores
              geometries as little-endian values.
      </p>
     </li>
     <li class="listitem">
      <p>
       MySQL supports geometry types of
       <code class="literal">
        Point
       </code>
       ,
       <code class="literal">
        LineString
       </code>
       ,
       <code class="literal">
        Polygon
       </code>
       ,
       <code class="literal">
        MultiPoint
       </code>
       ,
       <code class="literal">
        MultiLineString
       </code>
       ,
       <code class="literal">
        MultiPolygon
       </code>
       , and
       <code class="literal">
        GeometryCollection
       </code>
       . Other geometry
              types are not supported.
      </p>
     </li>
     <li class="listitem">
      <p>
       Only
       <code class="literal">
        GeometryCollection
       </code>
       can be empty.
              Such a value is stored with 0 elements.
      </p>
     </li>
     <li class="listitem">
      <p>
       Polygon rings can be specified both clockwise and
              counterclockwise. MySQL flips the rings automatically when
              reading data.
      </p>
     </li>
    </ul>
   </div>
   <p>
    Cartesian coordinates are stored in the length unit of the
          spatial reference system, with X values in the X coordinates
          and Y values in the Y coordinates. Axis directions are those
          specified by the spatial reference system.
   </p>
   <p>
    Geographic coordinates are stored in the angle unit of the
          spatial reference system, with longitudes in the X coordinates
          and latitudes in the Y coordinates. Axis directions and the
          meridian are those specified by the spatial reference system.
   </p>
   <p>
    The
    <a class="link" href="string-functions.html#function_length">
     <code class="literal">
      LENGTH()
     </code>
    </a>
    function returns
          the space in bytes required for value storage. Example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa67219867"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POINT(1 -1)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LENGTH</span><span class="token punctuation">(</span><span class="token variable">@g</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> LENGTH(@g) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>         25 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span><span class="token variable">@g</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> HEX(@g)                                            <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 000000000101000000000000000000F03F000000000000F0BF <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
   <p>
    The value length is 25 bytes, made up of these components (as
          can be seen from the hexadecimal value):
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       4 bytes for integer SRID (0)
      </p>
     </li>
     <li class="listitem">
      <p>
       1 byte for integer byte order (1 = little-endian)
      </p>
     </li>
     <li class="listitem">
      <p>
       4 bytes for integer type information (1 =
       <code class="literal">
        Point
       </code>
       )
      </p>
     </li>
     <li class="listitem">
      <p>
       8 bytes for double-precision X coordinate (1)
      </p>
     </li>
     <li class="listitem">
      <p>
       8 bytes for double-precision Y coordinate (−1)
      </p>
     </li>
    </ul>
   </div>
  </div>
 </div>
 <br/>
</div>
