ST_Centroid

定义

ST_Centroid 以面或多面要素为输入,然后返回位于几何的包络矩形中心的点。这意味着,质心点在几何的最小和最大 x 和 y 范围的中间位置。

语法

sde.st_centroid (pl1 sde.st_geometry)
sde.st_centroid (mpl1 sde.st_geometry)

返回类型

ST_Point

示例

城市 GIS 技术人员想要在建筑物密度图中将建筑物覆盖区多面显示为单个点。建筑物覆盖区存储在使用以下语句创建和填充的 bfp 表中:

CREATE TABLE bfp (
building_id integer,
footprint sde.st_geometry);

INSERT INTO bfp VALUES (
1,
sde.st_polygon ('polygon ((0 0, 0 10, 10 10, 10 0, 0 0))', 0)
);

INSERT INTO bfp VALUES (
2,
sde.st_polygon ('polygon ((20 0, 30 20, 40 0, 20 0))', 0)
);

INSERT INTO bfp VALUES (
3,
sde.st_polygon ('polygon ((20 30, 25 35, 30 30, 20 30))', 0)
);

ST_Centroid 函数返回每个建筑物覆盖区多面要素的质心。ST_AsText 函数将每个质心点转换为应用程序可识别的文本表示。

Oracle

SELECT building_id,
sde.st_astext (sde.st_centroid (footprint)) Centroid
FROM bfp;

BUILDING_ID                   Centroid

   1                     POINT  (5.00000000 5.00000000)
   2                     POINT  (30.00000000 10.00000000)
   3                     POINT  (25.00000000 32.50000000)

PostgreSQL

SELECT building_id,
sde.st_astext (sde.st_centroid (footprint)) 
AS centroid
FROM bfp;

building_id                  centroid

   1                     POINT  (5 5)
   2                     POINT  (30 10)
   3                     POINT  (25 33)
9/15/2013