ST_Centroid(geometry) 函數(shù)

2018-10-18 15:05 更新

ST_Centroid(geometry) 函數(shù) -= 作用:

獲取幾何對象的中心點

語法:

ST_Centroid (geometry Data Type)

返回類型:

PostGis return type: geometry

Examples: 例 1:

SELECT ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )');


------------------------------------------
010100000062277662277602406227766227760A40

例 2:

SELECT ST_AsText(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));


------------------------------------------
POINT(2.30769230769231 3.30769230769231)
(1 row)

例 3:

SELECT st_asgeojson(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));


---------------------------------------
{"type":"Point","coordinates":[2.30769230769231,3.30769230769231]}

參考文獻:

1.https://docs.microsoft.com/zh-cn/sql/t-sql/spatial-geometry/stcentroid-geometry-data-type

2.http://www.postgis.net/docs/ST_Centroid.html

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號