MySQL 5.0 Reference Manual  /  ...  /  Geometry Format Conversion Functions

12.14.6 Geometry Format Conversion Functions

MySQL supports the functions listed in this section for converting geometry values from internal geometry format to WKT or WKB format.

In addition, there are functions to convert a string from WKT or WKB format to internal geometry format. See Section 12.14.3, “Functions That Create Geometry Values from WKT Values”, and Section 12.14.4, “Functions That Create Geometry Values from WKB Values”.

  • AsBinary(g), AsWKB(g)

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

    SELECT AsBinary(g) FROM geom;
    
  • AsText(g), AsWKT(g)

    Converts a value in internal geometry format to its WKT representation and returns the string result.

    mysql> SET @g = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT AsText(GeomFromText(@g));
    +--------------------------+
    | AsText(GeomFromText(@g)) |
    +--------------------------+
    | LINESTRING(1 1,2 2,3 3)  |
    +--------------------------+
    

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