# Jason ---分享,共同进步

## POSTGIS常用函数

Management Functions

1,基本操作函数

AddGeometryColumn(<schema_name>, <table_name>, <column_name>, <srid>, <type>, <dimension>)

DropGeometryColumn(<schema_name>, <table_name>, <column_name>)

ST_SetSRID(geometry, integer)

2. Geometry Relationship Functions
几何空间数据关系函数

ST_Distance(geometry, geometry)

ST_DWithid(geometry, geometry, float)

ST_Equals(geometry, geometry)

equals('LINESTRING(0 0, 10 10)','LINESTRING(0 0, 5 5, 10 10)') 返回 TRUE。

ST_Disjoint(geometry, geometry)

ST_Intersects(geometry, geometry)

Intersects(g1, g2 ) --> Not (Disjoint(g1, g2 ))

ST_Touches(geometry, geometry)

a.Touches(b) -> (I(a) intersection I(b) = {empty set} ) and (a intersection b) not empty

ST_Crosses(geometry, geometry)

ST_Within(geometry A, geometry B)

ST_Overlaps(geometry, geometry)

ST_Contains(geometry A, geometry B)

ST_Covers(geometry A, geometry B)

ST_CoveredBy(geometry A, geometry B)

3,Geometry Processing Functions

ST_Centroid(geometry)

ST_Area(geometry)

ST_Length(geometry)

ST_PointOnSurface(geometry)

ST_Buffer(geometry, double, [integer])
buffer操作一个很有用函数，

，单位的换算关系如下：
1英里= 63360 米
1米=1/1852 海里
1海里= 1/60度

500*1/1852*1/60（度）

ST_Envelope(geometry)

ST_extent(geometry set)

ST_Difference(geometry A, geometry B)

select ST_AsEWKT(ST_Difference(geomfromText('LINESTRING(1 1,2 3,3 4,3 1)'),geomfromText('LINESTRING(2 0,2 2,5 2,3 1)')))

select ST_AsEWKT(ST_Difference(geomfromText('POLYGON((1 1,2 3,3 4,3 1,1 1))'),geomfromText('POLYGON((2 0,2 2,5 2,1 3,2 0))')))

ST_Union(geometry, geometry)

4 ，Geometry Accessors

ST_AsText(geometry)

(0,0 0,1 1,1 1,0 0,0)

ST_SRID(geometry)

ST_IsClosed(geometry)

ST_IsRing(geometry)

ST_NumPoints(geometry)

GeometryType(geometry)

select GeometryType(geomfromText('MULTILINESTRING((1 1,2 3,3 4,3 1,2 1,1 1),(1 2,2 3,4 5))'))

posted on 2008-03-24 16:46 agun 阅读(7743) 评论(5)  编辑  收藏 所属分类: 数据库

## #re: POSTGIS常用函数[未登录]  回复更多评论

2008-03-25 09:30 | test

## #re: POSTGIS常用函数  回复更多评论

2008-04-25 10:23 | 路过