名称

ST_PointOnSurface — 计算保证位于多边形或几何体上的点。

大纲

geometry ST_PointOnSurface(geometry g1);

描述

返回保证位于曲面内部的POINTPOLYGONMULTIPOLYGONCURVEPOLYGON) 。 在 PostGIS 中,此函数也适用于线和点几何图形。

此方法实现了 SQL 1.1 的 OGC 简单功能规范。 s3.2.14.2 // s3.2.18.2

该方法实现了SQL/MM规范。 SQL-MM 3:8.1.5、9.5.6。 该规范仅针对表面几何形状定义 ST_PointOnSurface。 PostGIS扩展了功能以支持所有常见的几何类型。 其他数据库(Oracle、DB2、ArcSDE)似乎仅支持曲面的此功能。 SQL Server 2008 支持所有常见的几何类型。

该函数支持 3d 并且不会丢失 z-index。

示例

Point on surface of a MultiPoint.

Code
SELECT ST_PointOnSurface(
  'MULTIPOINT (8 24,10 92,12 154,17 68,28 10,29 52,29 84,55 50,56 24,131 14,160 180,189 180)');
栅格输出
POINT(55 50)
Figure
Geometry figure for st-pointonsurface-multipoint

Point on surface of a LineString.

Code
SELECT ST_PointOnSurface(
  'LINESTRING (190 160,10 190,40 90,20 70,10 10,30 40,30 10,110 40,70 10,110 10,140 40,140 10,160 30,180 10)');
栅格输出
POINT(40 90)
Figure
Geometry figure for visual-st-pointonsurface-02

Point on surface of a Polygon.

Code
SELECT ST_PointOnSurface(
  'POLYGON ((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190))');
栅格输出
POINT(35 80)
Figure
Geometry figure for visual-st-pointonsurface-03

Point on surface of the highest-dimension components of a GeometryCollection.

Code
SELECT ST_PointOnSurface(
  'GEOMETRYCOLLECTION (POLYGON ((190 170,180 100,80 140,80 160,130 160,110 180,110 190,180 180,190 170)),
    LINESTRING (80 120,120 20,140 70,150 30,180 50,190 10),
    MULTIPOINT (19 150,22 49,30 13,32 101,45 35,67 88,75 16))');
栅格输出
POINT(133.571 150)
Figure
Geometry figure for visual-st-pointonsurface-04
Code
SELECT ST_PointOnSurface('LINESTRING(0 5 1,0 0 1,0 10 2)');
栅格输出
st_asewkt
--------------
 POINT(0 0 1)
(1 row)
Figure
Geometry figure for visual-st-pointonsurface-05

示例:ST_PointOnSurface 的结果保证位于多边形内,而 ST_Centroid计算的点可能位于多边形外。

Code
SELECT ST_PointOnSurface(geom) AS pt_on_surf, ST_Centroid(geom) AS centroid
    FROM (SELECT 'POLYGON ((130 120,120 190,30 140,50 20,190 20,
                      170 100,90 60,90 130,130 120))'::geometry AS geom) AS t;
栅格输出
pt_on_surf    |                  centroid
-----------------+---------------------------------------------
 POINT(62.5 110) | POINT(100.18264840182648 85.11415525114155)
Figure
Geometry figure for visual-st-pointonsurface-06