15

I have table with column name,Latitude and Longitude.I want to update this with polygon name and its centroid latitude longitude.I know there is a function in postgis st_centroid(geometry). But I want to enter x value and Y value in a separate column.How can I do this?

2
  • You want to write x and y of the centroid into new columns/attributes? Commented Sep 24, 2012 at 6:45
  • Yes, I have latitude and longitude columns.But St_centroid returns lat long value in a single column Commented Sep 24, 2012 at 6:52

1 Answer 1

21

Try:

UPDATE polygon_layer SET longitude=ST_X(ST_Centroid(geom)), Latitude=ST_Y(ST_Centroid(geom)); 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.