Fetching Spatial Data

Geometry values stored in a table can be fetched with conversion in internal format. You can also convert them into WKT or WKB format.

Fetching Spatial Data in Internal Format

Fetching geometry values using internal format can be useful in table-to-table transfers:

CREATE TABLE geom2 (g GEOMETRY) SELECT g FROM geom;

Fetching Spatial Data in WKT Format

The AsText() function provides textual access to geometry values. It converts a geometry from internal format into a WKT string.

mysql> SELECT AsText(g) FROM geom;
+-------------------------+
| AsText(p1)              |
+-------------------------+
| POINT(1 1)              |
| LINESTRING(0 0,1 1,2 2) |
+-------------------------+

Fetching Spatial Data in WKB Format

The AsBinary() function provides binary access to geometry values. It converts a geometry from internal format into a BLOB containing the WKB value.

SELECT AsBinary(g) FROM geom;