My table has a geometric field, in EPSG:3857, of type point. I need the latitude and longitude, in EPSG: 4326, of each point. Could someone give me a valid example of how to use ST_Transform().
From the PostGIS docs,
ST_Transform — Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.
geometry ST_Transform (geometry g, integer srid);
So, to read transformed points
SELECT ST_AsText (ST_Transform (geom, 4326)) FROM table ...
If you want long and lat as separate fields
SELECT ST_X (ST_Transform (geom, 4326)) AS long, ST_Y (ST_Transform (geom, 4326)) AS lat FROM table ...
These st_x/st_y functions are confusing. I am working with PostGresQL/PostGIS 2.4 as we speak. This is the bounding rect roughly enclosing the country of Kenya:
bounds.northeast = new LatLng(4.959918, 41.012352); bounds.southwest = new LatLng(-1.603490, 33.849266);
Converting one of the points into a geometry object, then use st_x() = 4.95... st_y()=41.012... If you use google maps, x is latitude and y is longitude !