Create centroid from field POSTGRESQL

40 Views Asked by At

I would like to create a centroid from a field that contains all the points that define a polygon. When apply the query for the coordinates is working but when trying to do the same for the field I get Invalid WKT: Invalid number: polygon (line 1)

My field "coord" contains data like: 46.781231 23.489355,46.785255 23.484876,46.786118 23.485407,46.787913 23.486857, 46.781231 23.489355

This one works :

SELECT  ST_centroid(ST_GeometryFromText('polygon((46.781231 23.489355,46.785255 23.484876,46.786118 23.485407,46.787913 23.486857, 46.781231 23.489355))'));

This one doesn't:

SELECT  ST_centroid(ST_GeometryFromText('polygon((coord))'))
from polygon_data;
0

There are 0 best solutions below