`
wsql
  • 浏览: 11808971 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

ArcGIS GeoDatabase ST_Geometry简介

 
阅读更多

ArcGISGeoDatabase ST_Geometry简介

1使用ST_Geometry存储空间数据(oracle)

1.1简介

ArcSDE for Oracle提供了ST_Geometry类型来存储几何数据。ST_Geometry是一种遵循ISO和OGC规范的,可以通过SQL直接读取的空间信息存储类型。采用这种存储方式能够更好的利用oracle的资源,更好的兼容oracle的特征,比如复制和分区,并且能够更快的读取空间数据。使用ST_Geometry存储空间数据,可以把业务数据和空间数据存储到一张表中(使用SDENBLOB方式业务数据和空间数据是分开存储在B表和F表中的),因此可以很方便的在业务数据中增加空间数据(只需要在业务表中增加ST_Geometry列)。使用这种存储方式还能够简化多用户的读取,管理(只需要管理一张表)。
从 ArcGIS 9.3开始,新的 ArcSDE geodatabases for Oracle 会默认使用ST_Geometry 方式来存储空间数据。它实现了SQL3规范中的用户自定义类型(user-defineddata types),允许用户使用ST_Geometry类型创建列来存储诸如界址点,街道,地块等空间数据。
使用ST_Geometry类型存储空间数据,具有以下优势:

1)通过SQL函数( ISO SQL/MM 标准)直接访问空间数据;

2)使用SQL语句存储、检索操纵空间数据,就像其他类型数据一样。

3)通过存储过程来进行复杂的空间数据检索和分析。

4)其他应用程序可以通过SQL语句来访问存储在geodatabase中的数据。从ArcGIS 9.3开始,新的ArcSDE geodatabases for Oracle 要求所以ST 函数调用的时候前面都要加上 SDE schema名称。例如:要对查询出来的空间数据进行union操作,则SQL函数需要这样写:"sde.ST_Union",在9,2版本之前,可以不加SDE schema名称。


1.2存储结构

ST_Geometry存储空间数据的结构如下表:
Name Type
ENTITY NUMBER(38)
NUMPTS NUMBER(38)
MINX FLOAT(64)
MINY FLOAT(64)
MAXX FLOAT(64)
MAXY FLOAT(64)
MINZ FLOAT(64)
MAXZ FLOAT(64)
MINM FLOAT(64)
MAXM FLOAT(64)
AREA FLOAT(64)
LEN FLOAT(64)
SRID NUMBER(38)
POINTS BLOB
Entity:为要素类型,包括(linestring,multilinestring, multipoint, multipolygon, point, or polygon)。具体的值对应的类型可以通过 st_geom_util 存储过程获得。 NUMPTS为坐标点的个数
Minx, miny, maxx, maxy :对应几何的外包络矩形
Area: 几何的面积
Len :几何的周长
SRID :空间参考系ID,对应 ST_Spatial_References 表中的空间参考信息
POINTS: 坐标序列

1.3操作函数

下面是一些针对ST_Geometry进行操作的函数,输入为ST_Geometry类型数据,输出为Number型数据、
ST_Area 返回几何的面积。
ST_Len 返回几何的周长。
ST_Entity 返回几何类型.
ST_NumPoints 返回几何坐标点的个数.
ST_MinM, ST_MinX, ST_MinY, ST_MinZ 返回几何不同维度的最小坐标. ST_MaxM,ST_MaxX, ST_MaxY, ST_MaxZ 返回几何不同维度的最大坐标. ST_SRID 返回空间参考系ID.
Get_release 返回版本信息.
如下面例子,在us_states表中查找所有state的名字并计算state的面积。
SELECT name, st_area(geometry)
FROM us_states
ORDER BY name;

1.4构造ST_Geometry对象

ST_LineString,ST_MultiLineString, ST_MultiPoint, ST_MultiPolygon, ST_Point, 和ST_Polygon 全部是ST_Geometry的子类. ST_Geometry和他的子类共享属性和方法. ST_LineString,ST_MultiLineString, ST_MultiPoint, ST_MultiPolygon, ST_Point and ST_Polygon的构造函数的定义是相同的,构造函数的名字就是类型名。
ST_Point是个有限对象(只有一个点),因此可以使用下面的方法来构造。
1,使用xy坐标和SRID来构造ST_Point
METHOD
FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
Argument Name Type In/Out Default?
PT_X NUMBER IN
PT_Y NUMBER IN
SRID NUMBER IN
SQL> insert into sample_pt values (ST_Point (10, 20, 1) );
2,使用xy坐标、高程值(z)和SRID来构造ST_Point
METHOD
FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
Argument Name Type In/Out Default?
PT_X NUMBER IN
PT_Y NUMBER IN
PT_Z NUMBER IN
SRID NUMBER IN
SQL> insert into sample_pt values (ST_Point (10, 20, 5, 1) );
3,使用xy坐标、高程值(z),量测值(m)和SRID来构造ST_Point
METHOD
FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
Argument Name Type In/Out Default?
PT_X NUMBER IN
PT_Y NUMBER IN
PT_Z NUMBER IN
MEASURE NUMBER IN
SRID NUMBER IN
SQL> insert into sample_pt values (ST_Point (10, 20, 5, 401, 1) );

1.5用户权限限制

在oracle使用ST_Geometry ,用户必须有以下权限:
CREATE TYPE
UNLIMITED TABLESPACE
CREATE LIBRARY
CREATE OPERATOR
CREATE INDEXTYPE
CREATE PUBLIC SYNONYM
DROP PUBLIC SYNONYM
The CONNECT and RESOURCE roles include these privileges.

2为使用ST_Geometry SQL函数配置oracle的网络服务

访问存储在oracle中的ST_Geometry类型数据的SQL函数通过扩展oracle的external procedure agent或者extproc来实现,因此,直接使用这些SQL函数需要配置oracle的listener,让oracle能够找到这些扩展库。如果使用SDE读取这些数据,则不需要配置。
这些对ST_Geometry类型数据进行操作的函数是用PL/SQL实现的,在PL/SQL中其实是转调的使用c语言编写的外部扩展库(ST_SHAPELIB)。
关于oracle的listener的详细配置方法请参考oracle的相关文档,下面主要介绍一下默认情况下如何配置(windows下面)。
1) 找到oracle数据库的安装目录(服务器端),然后定位到oraclehome\NETWORK\ADMIN目录
2) 备份listener.ora文件,这点很重要,在对oracle的配置做任何更改的时候都要进行备份
3) 打开listener.ora文件,找到 (PROGRAM = extproc) 这一行,在这行下面添加对ST_SHAPELIB的引用,即指定ST_SHAPELIB的地址,如下:
(ENVS="EXTPROC_DLLS=C:\ProgramFiles\ArcGIS\ArcSDE\ora10gexe\bin\st_shapelib.dll")
其中“C:\ProgramFiles\ArcGIS\ArcSDE\ora10gexe\bin\st_shapelib.dll”为ST_SHAPELIB的物理路径,可以根据安装情况自己修改。
4) 保存listener.ora文件,重新启动监听程序。
附录:
未修改前的listener.ora
# listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1
\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = zbc)(PORT = 1521))
)
)
修改后的listener.ora
# listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1
\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=C:\ProgramFiles\ArcGIS\ArcSDE\ora10gexe\bin\st_shapelib.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = zbc)(PORT = 1521))
)
)

3创建空间数据存储类型为ST_Geometry的要素类

创建空间数据存储类型为ST_Geometry的要素类有2种方法:
1)使用SDE创建要素类
从9.3 开始,默认创建的要素类都使用ST_Geometry存储空间数据,9.3 版本之前,可以通过配置dbtune参数来完成。
2)直接使用SQL语句创建要素类。
1. 首先使用sqlplus连接到oracle服务器,确保登陆用户有如下权限:
CREATE TYPE
UNLIMITED TABLESPACE
CREATE LIBRARY
CREATE OPERATOR
CREATE INDEXTYPE
CREATE PUBLIC SYNONYM
DROP PUBLIC SYNONYM
The CONNECT and RESOURCE roles include these privileges.
2. 使用SQL语句创建包含ST_Geometry列的表,注意:要使SDE能够认识你创建的要素类,新建的表中有且只能有一个ST_Geometry列,并且最好包含唯一标识的列。
执行下面的sql语句
CREATE TABLE sensitive_areas (area_id integer, name varchar(128),
area_size float, type varchar(10), zone sde.st_geometry);
注意st_geometry前面应添加sde schema 名,否则会报错。


51.png

3. 使用sdelayer命令,将创建好的表注册到SDE中
注册的时候一定要保证下面几点才能成功:
1必须是表的所有者才能注册。
2表中只能有一个ST_Geometry列。
3没有其他用户自定义类型的列。
4必须是简单的集合类型(points, lines,or polygons)。
5Geometry 必须是有效的,否则读取的时候会产生不可预期的错误。
sdelayer 命令参数如下:
sdelayer -o register -l <table,column> -e <entity_mask>[Spatial_Index]
[{-R <SRID> | [Spatial_Ref_Opts]}] [-P {BASIC | HIGH}]
{[-C NONE] | [-C <row_id_column>[,{SDE|USER}[,<min_ID>]]]}
[-E {empty | xmin,ymin,xmax,ymax}] [-t <storage_type>]
[-S <layer_description_str>] [-q]
[-k <config_keyword>] [-i <service>] [-s <server_name]
[-u <DB_User_name>] [-p <DB_User_password>] [-D<database>]

在命令行中执行下列命令
sdelayer -o register -l sensitive_areas,zone -e a -C area_id,SDE -u data -p sa-t ST_GEOMETRY
-o参数为register -l参数为 表名/ST_Geometry列 -e 几何类型 -C 用户唯一id/SDE 其中SDE表示由sde维护唯一id,使用USER选项,则有用户维护唯一ID -u 注册地用户名 -p 用户密码 -t 数据存储类型


sdelayer.png

barry~~~~~~~~~~~~~
4. 在catalog中查看,可以看到sensitive_areas已经被注册到sde中,并且图标显示为polygon类型。

使用SQL直接操纵FeatureClass(oracle),这里主要讲存储类型为ST_Geometry的要素类。
FeatureClass的操作主要包括下面几点:
1
数据的插入,删除,更新
数据的插入直接使用insert语句来进行,构造ST_Geometry的时候可以通过两种方法来完成:
1
)使用WKT编码
2
)使用WKB编码
上面两种编码都是OGC规范的编码方式,分别通过ST_PolyFromText()ST_PointFromWKB() 以及一系列类似函数还完成从WKTWKBST_Geometry转换。
下面为所有相关ST函数:
ST_GeomFromText—Creates an ST_Geometry from a text representation of anygeometry type
ST_PointFromText—Creates an ST_Point from a point text representation
ST_LineFromText—Creates an ST_LineString from a linestring text representation
ST_PolyFromText—Creates an ST_Polygon from a polygon text representation
ST_MPointFromText—Creates an ST_MultiPoint from a multipoint representation
ST_MLineFromText—Creates an ST_MultiLineString from a multilinestringrepresentation
ST_MPolyFromText—Creates an ST_MultiPolygon from a multipolygon representation
ST_AsText—converts an existing geometry into a text representation
ST_GeomFromWKB—Creates an ST_Geometry from a WKB representation of any geometrytype
ST_PointFromWKB—Creates an ST_Point from a point WKB representation
ST_LineFromWKB—Creates an ST_LineString from a linestring WKB representation
ST_PolyFromWKB—Creates an ST_Polygon from a polygon WKB representation
ST_MPointFromWKB—Creates an ST_MultiPoint from a multipoint WKB representation
ST_MLineFromWKB—Creates an ST_MultiLineString from a multilinestring WKBrepresentation
ST_MPolyFromWKB—Creates an ST_MultiPolygon from a multipolygon WKBrepresentation
ST_AsBinary—converts an existing geometry value into well-known binaryrepresentation.
关于wkt wkb的编码方式会在下一节讲。
下面就使用sql语句来进行数据的插入,执行下面的sql语句:
INSERT INTO sensitive_areas(area_id , name, area_size, type ,zone,fid)
VALUES (1, 'Summerhill Elementary School', 67920.64, 'school',sde.ST_PolyFromText('polygon
((52 28,58 28,58 23,52 23,52 28))', 0));
sensitive_areas表中插入一条记录。


insert.png

打开ArcMap,加载这个featureClass,可以看到新增加的这条记录。


arcmap.png

更新记录
UPDATEsensitive_areas
SET zone= sde.st_pointfromtext('polygon ((52 30,58 30,58 23,50 23,50 28))', 0))
WHERE area_id = 1;
删除记录
DELETE FROM sensitive_areas WHERE names
(SELECT sa.names
FROM sensitive_areas sa, hazardous_sites hs
WHERE sde.st_overlaps (sa.zone, sde.st_buffer (hs.location,.01)) = 1);
2
查询
在进行空间查询的时候会用到索引,其中infomix使用R树索引,PostgreSQ使用Generalized Search Tree(GiST) R-tree索引, oracle DB2 使用网格索引。
oracle中进行查询会执行下面的步骤:
1
)首先比较grid和查询范围,找出在查询范围内的所有grid
2
)找出在这些grid内的所有要素。
3
)将这些要素的外包络矩形和查询范围比较,找出所有在查询范围内以及和查询范围相交的要素。
4
)使用ST函数进行最终过滤(一般使用ST_IntersectsST_Contains),找到完全符合条件的要素。
下面是一个进行空间查询的例子:
SELECT sa.name "Sensitive Areas", hs.name "Hazardous Sites"
FROM sensitive_areas sa, hazardous_sites hs
WHERE sde.st_overlaps (sa.zone, sde.st_buffer(hs.location,.01)) = 1;
3
创建索引
CREATE INDEX sa_idx ON sensitive_areas(zone)
INDEXTYPE IS sde.st_spatial_index
PARAMETERS('st_grids=1,3,0 st_srid=0');


createindex.png

4
创建空间参考系
ESRI
建议最好使用ArcGIS Desktop来进行空间参考系的创建,但也可以使用SQL语句进行空间参考系的创建。执行下面的sql语句:
INSERT INTO SDE.ST_SPATIAL_REFERENCES VALUES (
GCS_North_American_1983,
1,
-400,
-400,
1000000000,
-100000,
10000,
-100000,
10000,
9.999E35,
-9.999E35,
9.999E35,
-9.999E35,
9.999E35,
-9.999E35,
9.999E35,
-9.999E35,
4269,
'GCS_North_American_1983',
'PROJECTED',
NULL,
'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID
["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT
["Degree",0.0174532925199433]]',
'ArcSDE SpRef'
);

4Wkt和Wkb

wkt(OGC well-knowntext)和wkb(OGCwell-known binary)是OGC制定的空间数据的组织规范,wkt是以文本形式描述,wkb是以二进制形式描述。
使用wkt和wkb能够很好到和其他系统进行数据交换,目前大部分支持空间数据存储的数据库构造空间数据都采用这两种方式。
wkt的组织结构如下:

Geometry type

Text description

Comment

ST_Point

'point empty'

empty point

ST_Point

'point z empty'

empty point with z-coordinate

ST_Point

'point m empty'

empty point with measure

ST_Point

'point zm empty'

empty point with z-coordinate and measure

ST_Point

'point ( 10.05 10.28 )'

point

ST_Point

'point z( 10.05 10.28 2.51 )'

point with z-coordinate

ST_Point

'point m( 10.05 10.28 4.72 )'

point with measure

ST_Point

'point zm(10.05 10.28 2.51 4.72 )'

point with z-coordinate and measure

ST_LineString

'linestring empty'

empty linestring

ST_LineString

'linestring z empty'

empty linestring with z-coordinates

ST_LineString

'linestring m empty'

empty linestring with measures

ST_LineString

'linestring zm empty'

empty linestring with z-coordinates and measures

ST_LineString

'linestring (10.05 10.28 , 20.95 20.89 )'

linestring

ST_LineString

'linestring z(10.05 10.28 3.09, 20.95 31.98 4.72, 21.98 29.80 3.51 )'

linestring with z-coordinates

ST_LineString

'linestring m(10.05 10.28 5.84, 20.95 31.98 9.01, 21.98 29.80 12.84 )'

linestring with measures

ST_LineString

'linestring zm(10.05 10.28 3.09 5.84, 20.95 31.98 4.72 9.01, 21.98 29.80 3.51 12.84)'

linestring with z-coordinates and measures

ST_Polygon

'polygon empty'

empty polygon

ST_Polygon

'polygon z empty'

empty polygon with z-coordinates

ST_Polygon

'polygon m empty'

empty polygon with measures

ST_Polygon

'polygon zm empty'

empty polygon with z-coordinates and measures

ST_Polygon

'polygon ((10 10, 10 20, 20 20, 20 15, 10 10))'

polygon

ST_Polygon

'polygon z((10 10 3, 10 20 3, 20 20 3, 20 15 4, 10 10 3))'

polygon with z-coordinates

ST_Polygon

'polygon m((10 10 8, 10 20 9, 20 20 9, 20 15 9, 10 10 8 ))'

polygon with measures

ST_Polygon

'polygon zm((10 10 3 8, 10 20 3 9, 20 20 3 9, 20 15 4 9, 10 10 3 8 ))'

polygon with z-coordinates and measures

ST_MultiPoint

'multipoint empty'

empty multipoint

ST_MultiPoint

'multipoint z empty'

empty multipoint with z-coordinates

ST_MultiPoint

'multipoint m empty'

empty multipoint with measures

ST_MultiPoint

'multipoint zm empty'

empty multipoint with z-coordinates and measures

ST_MultiPoint

'multipoint (10 10, 20 20)'

multipoint with two points

ST_MultiPoint

'multipoint z(10 10 2, 20 20 3)'

multipoint with z-coordinates

ST_MultiPoint

'multipoint m(10 10 4, 20 20 5)'

multipoint with measures

ST_MultiPoint

'multipoint zm(10 10 2 4, 20 20 3 5)'

multipoint with z-coordinates and measures

ST_MultiLineString

'multilinestring empty'

empty multilinestring

ST_MultiLineString

'multilinestring z empty'

empty multilinestring with z-coordinates

ST_MultiLineString

'multilinestring m empty'

empty multilinestring with measures

ST_MultiLineString

'multilinestring zm empty'

empty multilinestring with z-coordinates and measures

ST_MultiLineString

'multilinestring ((10.05 10.28 , 20.95 20.89 ),( 20.95 20.89, 31.92 21.45))'

multilinestring

ST_MultiLineString

'multilinestring z((10.05 10.28 3.4, 20.95 20.89 4.5),( 20.95 20.89 4.5, 31.92 21.45 3.6))'

multilinestring with z-coordinates

ST_MultiLineString

'multilinestring m((10.05 10.28 8.4, 20.95 20.89 9.5), (20.95 20.89 9.5, 31.92 21.45 8.6))'

multilinestring with measures

ST_MultiLineString

'multilinestring zm((10.05 10.28 3.4 8.4, 20.95 20.89 4.5 9.5), (20.95 20.89 4.5 9.5, 31.92 21.45 3.6 8.6))'

multilinestring with z-coordinates and measures

ST_MultiPolygon

'multipolygon empty'

empty multipolygon

ST_MultiPolygon

'multipolygon z empty'

empty multipolygon with z-coordinates

ST_MultiPolygon

'multipolygon m empty'

empty multipolygon with measures

ST_MultiPolygon

'multipolygon zm empty'

empty

ST_MultiPolygon

'multipolygon (((10 10, 10 20, 20 20, 20 15 , 10 10), (50 40, 50 50, 60 50, 60 40, 50 40)))'

multipolygon

ST_MultiPolygon

'multipolygon z(((10 10 7, 10 20 8, 20 20 7, 20 15 5, 10 10 7), (50 40 6, 50 50 6, 60 50 5, 60 40 6, 50 40 6)))'

multipolygon with z-coordinates

ST_MultiPolygon

'multipolygon m(((10 10 2, 10 20 3, 20 20 4, 20 15 5, 10 10 2), (50 40 7, 50 50 3, 60 50 4, 60 40 5, 50 40 7)))'

multipolygon with measures

ST_MultiPolygon

'multipolygon zm(((10 10 7 2, 10 20 8 3, 20 20 7 4, 20 15 5 5, 10 10 7 2), (50 40 6 7, 50 50 6 3, 60 50 5 4, 60 40 6 5, 50 40 6 7)))'

multipolygon with z-coordinates and measures

wkb的组织结构如下:
基本类型定义:
byte : 1 byte
uint32 : 32 bit unsigned integer(4 bytes)
double : double precision number (8 bytes)
Building Blocks : Point, LinearRing
Point {
double x;
double y;
};
LinearRing {
uint32 numPoints;
Point points[numPoints];
}
enum wkbGeometryType {
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6,
wkbGeometryCollection = 7
};
enum wkbByteOrder {
wkbXDR = 0, Big Endian
wkbNDR = 1 Little Endian
};
WKBPoint {
byte byteOrder;
uint32 wkbType; 1
Point point;
}
WKBLineString {
byte byteOrder;
uint32 wkbType; 2
uint32 numPoints;
Point points[numPoints];
}
WKBPolygon {
byte byteOrder;
uint32 wkbType; 3
uint32 numRings;
LinearRingrings[numRings];
}
WKBMultiPoint {
byte byteOrder;
uint32 wkbType; 4
uint32 num_wkbPoints;
WKBPoint WKBPoints[num_wkbPoints];
}
WKBMultiLineString {
byte byteOrder;
uint32 wkbType; 5
uint32 num_wkbLineStrings;
WKBLineString WKBLineStrings[num_wkbLineStrings];
}
wkbMultiPolygon {
byte byteOrder;

uint32 wkbType; 6
uint32 num_wkbPolygons;
WKBPolygonwkbPolygons[num_wkbPolygons];
}
WKBGeometry{
union {
WKBPoint point;
WKBLineString linestring;
WKBPolygon polygon;
WKBGeometryCollection collection;
WKBMultiPoint mpoint;
WKBMultiLineStringmlinestring;
WKBMultiPolygon mpolygon;
}
};
WKBGeometryCollection {
byte byte_order;
uint32 wkbType; 7
uint32 num_wkbGeometries;
WKBGeometrywkbGeometries[num_wkbGeometries]
}
下面是一个point(1,1) 使用WKB存储的例子:
0101000000000000000000F03F000000000000F03F
这个2进制流可以按照WKBPoint的结构进行拆分:
Byte order : 01
WKB type : 01000000
X : 000000000000F03F
Y : 000000000000F03F
byte order要么为0,要么为1,0为使用little-endian编码(NDR),1为使用big-endian编码(XDR)。
WKB type 是几何类型,在wkbGeometryType中定义. 值为1-7,分别对应 Point,LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, andGeometryCollection.
x,y为点的坐标值,为double类型。

5SQL函数介绍

在SDE中,可以直接使用SQL语句进行空间数据的操作,包括:
空间关系的判断,空间分析,以及空间数据属性的提取。
1 用于空间关系判断的函数主要有:
ST_Contains
当第二个几何完全被第一个几何包含的时候返回true

下载 (62.7 KB)

2009-4-22 15:29


用法:
sde.st_contains (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_contains的详细使用说明请参考SQLfunctions reference
ST_Crosses
当两个几何相交的时候返回true ,这个函数只适用于ST_MultiPoint/ST_Polygon,
ST_MultiPoint/ST_LineString,ST_Linestring/ST_LineString,ST_LineString/ST_Polygon, and ST_LineString/ST_MultiPolygon之间的比较。

下载 (34.02 KB)

2009-4-22 15:29


用法:
sde.st_crosses (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_crosses 的详细使用说明请参考SQLfunctions reference
ST_Disjoint
当两个几何不相交的时候返回true

下载 (60.12 KB)

2009-4-22 15:29


用法:
sde.st_disjoint (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_disjoint 的详细使用说明请参考SQL functionsreference
ST_Equals
当两个几何类型相同,并且坐标序列相同的时候返回true

下载 (43.09 KB)

2009-4-22 15:29


用法:
sde.st_equals (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_equals 的详细使用说明请参考SQLfunctions reference
ST_Intersects
当两个几何相交的时候返回true,是st_disjoint结果的非

用法:
sde.st_intersects (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_intersects 的详细使用说明请参考SQLfunctions reference
ST_Overlaps
当比较的2个几何维数相同并且相交,返回true

下载 (26.06 KB)

2009-4-22 15:29


用法:
sde.st_overlaps (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_overlaps的详细使用说明请参考SQLfunctions reference
ST_Touches如果两个几何相交的部分都不在两个几何的内部,则返回true

下载 (35.81 KB)

2009-4-22 15:29


用法:
sde.st_touches (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_touches的详细使用说明请参考SQLfunctions reference
ST_Within
如果第一个几何完全在第二个几何内部,则返回true,和ST_Contains的结果正好相反。

下载 (61.83 KB)

2009-4-22 15:29


用法:
sde.st_within (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_within的详细使用说明请参考SQLfunctions reference
注意:在使用判断空间关系的SQL函数的时候,应该把SQL函数做为在WHERE条件语句的第一个语句,这样
才能使用空间索引,不然就会使用全表扫描。
2 空间分析函数:
ST_Buffer
缓冲区分析

下载 (25.61 KB)

2009-4-22 15:29


用法:
sde.st_buffer (g1 sde.st_geometry, distance double_precision)
关于st_buffer的详细使用说明请参考SQLfunctions reference
ConvexHull
求几何的外包多边形,如果几何的顶点个数小于三个ConvexHull函数返回null
用法:
sde.st_convexhull (g1 sde.st_geometry)
关于st_convexhull的详细使用说明请参考SQLfunctions reference
ST_Difference
求两个几何的Difference ,下图中第一个几何为黑色,第二个几何为橘黄色

下载 (68.66 KB)

2009-4-22 15:29


用法:
sde.st_difference (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_difference的详细使用说明请参考SQLfunctions reference
ST_Intersection
求两个几何的交

下载 (72.32 KB)

2009-4-22 15:29


用法:
sde.st_intersection (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_intersection的详细使用说明请参考SQLfunctions reference
ST_SymmetricDiff
求几何的异或

下载 (81.08 KB)

2009-4-22 15:29


用法:
sde.st_symmetricdiff (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_symmetricdiff 的详细使用说明请参考SQLfunctions reference
ST_Union
求几何的并

下载 (78.84 KB)

2009-4-22 15:29


用法:
sde.st_union (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_union的详细使用说明请参考SQLfunctions reference
ST_Distance
求两个几何间的最短距离

下载 (58.85 KB)

2009-4-22 15:29


用法:
sde.st_distance (g1 sde.st_geometry, g2 sde.st_geometry)
关于st_distance的详细使用说明请参考SQLfunctions reference
聚集函数:
ST_Aggr_ConvexHull
返回一个multipolygon,这个multipolygon是所有输入几何的外包多边形。
ST_Aggr_Intersection
求所有输入几何相交的部分,返回一个几何
ST_Aggr_Union
求所有输入几何的并,返回一个几何,注意,这个函数只支持相同类型进行聚合合并
3空间数据属性提取的函数主要有:
1)求几何维度的函数:
ST_Dimension
ST_CoordDim
2) z值函数
ST_Is3D
ST_Z
ST_MaxZ
ST_MinZ
3)量测值函数
ST_IsMeasured
ST_M
4)取几何类型函数
ST_GeometryType
ST_Entity
5)ST_Point相关函数
ST_X
ST_Y
ST_Z
ST_M
6)面积和长度函数
ST_Length
ST_Area
7)ST_LineString相关函数
ST_StartPoint—Returns the first point of the specified ST_LineString
ST_EndPoint—Returns the last point of an ST_LineString
ST_PointN—Takes an ST_LineString and an index to nth point and returns thatpoint
ST_Length—Returns the length of an ST_LineString as a double-precision number
ST_NumPoints—Evaluates an ST_LineString and returns the number of points in itssequence
as an integer
ST_IsRing—A predicate function that returns 1 (TRUE) if the specifiedST_LineString is a
ring and 0 (FALSE) otherwise
ST_IsClosed—A predicate function that returns 1 (TRUE) if the specifiedST_LineString is
closed and 0 (FALSE) if it is not
8)ST_MultiLineString 相关函数
ST_Length —returns the cumulative length of all of its ST_LineString elementsas a double
-precision number.
ST_IsClosed—returns 1 (TRUE) if the specified ST_MultiLineString is closed and0 (FALSE)
if it is not closed.
9)ST_Polygon相关函数
ST_Area—Returns the area of an ST_Polygon as a double-precision number
ST_Centroid—Returns an ST_Point that represents the center of the ST_Polygon'senvelope
ST_ExteriorRing—Returns the exterior ring of an ST_Polygon as an ST_LineString
ST_InteriorRingN—Evaluates an ST_Polygon and an index and returns the nthinterior ring as
an ST_LineString
ST_NumInteriorRing—Returns the number of interior rings that an ST_Polygoncontains
ST_PointOnSurface—Returns an ST_Point that is guaranteed to be on the surfaceof the
specified ST_Polygon
10)ST_MultiPolygon相关函数
ST_Area —returns a double-precision number that represents the cumulativeST_Area of an
ST_MultiPolygon's ST_Polygon elements.
ST_Centroid — an ST_Point that is the center of an ST_MultiPolygon's envelope.
ST_PointOnSurface —returns an ST_Point that is guaranteed to be normal to thesurface of
one of its ST_Polygon elements.
11)求几何坐标点个数函数
ST_NumGeometries— returns a count of the individual elements in a collection of
geometries.
ST_GeometryN — you can determine which geometry in the multipart geometryexists in
position N; N being a number you provide with the funciton。
12)空间参考系相关函数
ST_SRID
ST_EqualSRS
13) 其他函数
ST_Boundary
ST_IsSimple
ST_IsClosed
ST_IsRing
ST_IsEmpty
ST_Envelope



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics