Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This line: SELECT geom FROM myLayer.geom will return a hex value, i'm wondering how would it be possible to get decimal values, a result that look likes human-readable coordination?


share|improve this question
up vote 25 down vote accepted

In addition to ST_AsText (which returns geometry as WKT / Well Known Text), there are several additional output formats, like ST_AsGeoJSON().

Take a look in and choose, what fits your needs best.

share|improve this answer

use this for point object:

SELECT ST_AsText(the_geom) 
       FROM myTable;

and viewing X,Y and geom object:

SELECT ST_X(the_geom), ST_Y(the_geom), ST_AsText(the_geom) 
       FROM myTable;

i hope it helps you...

share|improve this answer
I believe that ST_X & ST_Y will work only with points. They do not work with polygons or lines. – Devdatta Tengshe Jul 31 '13 at 9:16
you are right Devdatta. it works only for points. ST_X — Return the X coordinate of the point, or NULL if not available. Input must be a point. i have updated my answer. – Aragon Jul 31 '13 at 9:19
For polygons/lines, use st_x(st_centroid(the_geom)) – Steve Bennett Sep 18 '13 at 22:26
SELECT * ST_AsText(the_geom) FROM table2;

Source: Beginner PostGIS question: getting geometry from multiple tables

share|improve this answer

With a table in UTM

ST_X(table.geometry) AS X1, --point x
ST_Y(table.geometry) AS Y1, --point y
ST_X(ST_TRANSFORM(table.geometry,4674)) AS LONG, -- longitude point x SIRGAS 2000
ST_Y(ST_TRANSFORM(table.geometry,4674)) AS LAT, --latitude point y SIRGAS 2000
ST_ASTEXT(table.geometry) AS XY, --wkt point xy
ST_ASTEXT(ST_TRANSFORM(table.geometry,4674)) AS LongLat --using st_transform to get wkt with longitude and latitude (4674 is the SIRGAS 2000 SRC by south america)
share|improve this answer

I solved this problem with Java + Ibatis implementing the interface TypeHandlerCallback.

You need to add postgis.jar lib; Create a handle class implement TypeHandlerCallback from Ibatis;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.