文档

ST_Centroid

更新时间:

返回给定Geometry对象或Geography对象的形心。

语法

geometry ST_Centroid(geometry g1);
geography ST_Centroid(geography g1 , boolean useSpheroid);

参数

参数名称

描述

g1

目标Geometry对象或Geography对象。

useSpheroid

对于Geography对象,是否使用椭球模式。默认为True。

描述

  • MULTIPOINT的形心:

    SELECT ST_AsText(ST_Centroid('MULTIPOINT(1 1,-1 -1)'::geometry));
     st_astext
    ------------
     POINT(0 0)
    (1 row)
                        
  • LINESTRING的形心:

    SELECT ST_AsText(ST_Centroid('LINESTRING(0 0,0 1,1 2)'::geometry));
                     st_astext
    -------------------------------------------
    POINT(0.292893218813453 1.085786437626905)
    (1 row)
                        
  • 本页导读 (1)
文档反馈