PostGIS解析Geometry几何对象

一、Geometry转WKT

select st_astext(geom) where tableName;

 

二、PostGIS常用函数

wkt转geometry st_geomfromtext(wkt,wkid)

geometry转wkt st_astext(geom)

获取点对象x、y坐标值 st_x(geom)、st_y(geom)

获取线/面对象四至 st_xmin(geom)、st_ymin(geom)、st_xmax(geom)、st_ymax(geom)

计算两点之间距离 st_distance(geom,geom) / st_distance(wkt,wkt)

计算线的长度 st_length(geom) / st_length(wkt)

计算面积 st_area(geom) / st_area(wkt)

缓冲区计算 st_buffer(geom,distance) / st_buffer(wkt,distance)

 

WKT几种对象格式

POINT(0 0) ——点
LINESTRING(0 0,1 1,1 2) ——线
POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1)) ——面
MULTIPOINT(0 0,1 2) ——多点
MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) ——多线
MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1))) ——多面
GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4))) ——几何集合

posted @ 2018-12-29 17:18  BretGui  阅读(3573)  评论(0编辑  收藏  举报