如何在Postgis中获取多边形质心


12

我有带有列名称,纬度和经度的表。我想用多边形名称及其质心的纬度经度更新此表。我知道postgis st_centroid(geometry)中有一个函数。但是我想在单独的栏中输入x值和Y值,该怎么办?


您想将质心的x和y写入新的列/属性吗?
昏暗

是的,我有经度和纬度列。但是St_centroid在单个列中返回纬度长值
Sreesha 2012年

Answers:


19

尝试:

UPDATE polygon_layer SET longitude=ST_X(ST_Centroid(geom)), Latitude=ST_Y(ST_Centroid(geom));
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.