I have a PostGIS table with a geometry field of SRID 3857 data. I want to get the centroid of the geometry as lat/lon coordinates, but can't seem to convert the values correctly:
SELECT
ST_X(ST_CENTROID(geometry)),
ST_Y(ST_CENTROID(geometry)),
ST_X(ST_TRANSFORM(ST_CENTROID(geometry),3857)) AS LONG,
ST_Y(ST_CENTROID(ST_TRANSFORM(geometry,3857))) AS LAT
FROM my_table
=> -8220067.19453888107, 4997528.08142071683, -8220067.19453888107, 4997528.08142071683