Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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? Please help me

Regards, Sreesha

share|improve this question
    
You want to write x and y of the centroid into new columns/attributes? –  underdark Sep 24 '12 at 6:45
    
Yes, I have latitude and longitude columns.But St_centroid returns lat long value in a single column –  Sreesha Sep 24 '12 at 6:52
add comment

1 Answer 1

Try:

UPDATE polygon_layer SET longitude=ST_X(ST_Centroid(geom)), Latitude=ST_Y(ST_Centroid(geom));
share|improve this answer
    
thanks.Its working –  Sreesha Sep 24 '12 at 9:23
    
@Sreesha: Remember to mark his answer as accepted. –  CaptDragon Sep 24 '12 at 13:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.