Home > Net >  Is there any way to get latitudes and longitudes from Postgres geography type column
Is there any way to get latitudes and longitudes from Postgres geography type column

Time:04-21

I have a column of data type geography in a Postgres table. Column Data Type

When I query it from DB it shows like this,

Sample Values

Now I'm trying to query the table with psycopg2 but instead of the points (lat, long), I'm getting some huge string. enter image description here

What is this pattern and How I can cast it to get latitudes and longitudes?

I have tried searching over the internet but unluckily no help found.

CodePudding user response:

You can get the text representation with the dt_astext function, or you can type cast to geometry and use the st_y and st_y functions.

  • Related