Monsieur
Monsieur

Reputation: 117

PostGIS update geo column with ST_GeogFromText and get lon/lat from another column

I started to use PostGIS recently and i have a table with a column longitudes and a column latitudes.
I want to know if it's possible (and how) to put these lon/lat columns informations into the new geographical column (with possibly ST_GeogFromText)

I already tried something like :

UPDATE my_table SET geo = ST_GeogFromText('SRID=4267;POINT(lon.my_table lat.my_table)');

Thanks for your reading and you help.

Upvotes: 0

Views: 678

Answers (1)

Mike T
Mike T

Reputation: 43642

ST_GeogFromText takes a formatted text of EWKT, which is a lossy and inefficient method.

Try using ST_MakePoint instead:

UPDATE my_table SET geo = ST_SetSRID(ST_MakePoint(lon, lat), 4267)::geography;

Upvotes: 2

Related Questions