Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Introduction to spatial databases
4. Foretaste of part 2
Short quiz


For our purposes, the most important format for geometries will be Well-Known Text (WKT), which is a text representation that human beings can actually read. In order to convert a geometry column into WKT, we have to use the ST_AsText function, like so:

FROM st_atms

Thanks to this function, instead of a crazy sequence of characters that make no sense to us, we can get a nice and neat and relatively comprehensible form of something like: POINT(-122.392016105263 37.6138040015053). From the name, you can immediately tell that the above data represents a point. Furthermore, its coordinates are specified inside the parentheses. We'll discuss this in detail in the next part of the course. Stay tuned!


In our database there is a table called sf_tram_stops. Select the following columns from the table:

  • id,
  • coordinates,
  • coordinates column represented as WKT (name the column wkt).

You can now see that the wkt column is much more readable than the original coordinates column.

Stuck? Here's a hint!

In order to convert the coordinates column to text, use the ST_AsText(coordinates) function.