SQL求几何重心

时间:2022-01-22 00:20:51

ST_Centroid(geometry);

geometry :a specified ST_Geometry

e.g.:

select ST_AsText(ST_Centroid('0103000020E610000001000000050000000EBF9B6ED9775E40B96DDFA3FE723C4019E6046D72775E400CAD4ECE50743C40ED832C0B26785E40B6D9588979763C40A471A8DF85785E409605137F14753C400EBF9B6ED9775E40B96DDFA3FE723C40'));

结果:

POINT(121.874850835107 28.4559363140394)

ST_Centroid(ST_GeomFromText(text WKT));

WKT: Well-Known Text representation

e.g.:select ST_AsText(ST_Centroid(ST_GeomFromText('POLYGON((121.872646 28.449198,121.866359 28.454358,121.877322 28.462792,121.883171 28.457344,121.872646 28.449198))')));

结果:

POINT(121.874850835107 28.4559363140394)