codecamp

ST_Centroid(geometry) 函数

ST_Centroid(geometry) 函数 -= 作用:

获取几何对象的中心点

语法:

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

ST_AsGeoJSON 函数
CONCAT+ST_X+ST_Y生成X,Y坐标
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Oracle数据库.

MySQL数据库

Access数据库

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }