获取线的中间点(postgis)


前言:QGIS没找到对应功能,只有 Mean Coordinate(s) ,但不能满足要求,最后找到了 PostGIS 的相关方法。

ST_LineInterpolatePoint

函数详情

select ST_ASText(ST_LineInterpolatePoint (ST_LineMerge(geom), 0.5)) from line

这样就能获取中间点了。
ST_LineMerge是将multLineString 转成 LineString,即多线格式转为单线。
这个函数前提条件:线几何图形要求必须是单线,即存在两段组合的multLineString,那么就会报错

ST_ClosestPoint & ST_Centroid

select ST_ASText(ST_ClosestPoint(geom, ST_Centroid(geom))) from line

这个只能获取到近似中间点
原理是获取到中心点,再获取中心点离该线最近的那个点。线越是直的,那么越逼近中间点。这个不受多线的限制

转载自:https://blog.csdn.net/geol200709/article/details/86580009

You may also like...

退出移动版