I am using PostGIS to save geography data in type geography(POINT, 4326).
CREATE TABLE IF NOT EXISTS address ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), geog geography(POINT, 4326) NULL ) And I am using Psycopg in Python to access data in PostGIS.
What is the best way to get the latitude, longitude?
One possible way is use ST_AsText:
select geog, ST_AsText(geog) from address It will return geog as a string like POINT(104.5306 32.4089) and I can parse the string to get latitude and longitude.
Is there a better way do achieve what I want?
ST_XandST_Yfunctions in PostGIS?ST_X()andST_Y()for lon and lat (respectively) seems an obvious solution.