Oracle Spatial中缓冲分析使用SDO_GEOM.SDO_BUFFER函数实现,下面是SDO_GEOM包中SDO_BUFFER函数的原型:
function sdo_buffer(geom IN MDSYS.SDO_GEOMETRY,
dist IN NUMBER,
tol IN NUMBER,
params IN VARCHAR2)
return MDSYS.SDO_GEOMETRY DETERMINISTIC;
这里的dist为缓冲距离;tol为容差值;params代表2个可选参数,分别为unit=和arc_ tolerance=,这些可选参数可以帮助用户在地理坐标系的数据上直接进行投影距离的缓冲。
下面的操作是对一个经纬度点数据进行一个1000千米的缓冲后,再输出经纬度几何对象:
SQL> select sdo_geom.sdo_buffer(SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(0,0, NULL),NULL,NULL),1000,1,'arc_tolerance=0.1 unit=km') from dual;
SDO_GEOM.SDO_BUFFER(SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(0,0,NULL),NULL,NULL),1000,1,'ARC_TOLERANCE=0.1UNIT=KM')(SDO_GT
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(6.40486849, 6.40776286, 6.22416673, 6.58569883, 6.03847881, 6.758491, 5.84794461, 6.92599964, 5.65270846, 7.08808893, 5.45291911, 7.24462711, 5.24872964, 7.39548658, 5.04029736, 7.54054407, 4.82778372, 7.67968076, 4.61135423, 7.81278238, 4.39117828, 7.93973937, 4.16742907, 8.06044696, 3.94028348, 8.17480534, 3.70992187, 8.28271972, 3.476528, 8.3841005, 3.24028879, 8.47886329, 3.00139424, 8.56692911, 2.76003717, 8.64822438, 2.5164131, 8.72268111, 2.27072, 8.79023691, 2.02315813, 8.85083509, 1.77392981, 8.90442474, 1.52323924, 8.95096079, 1.27129222, 8.99040405, 1.01829598, 9.02272129, .764458942, 9.04788525, .509990466, 9.0658747, .255100632, 9.07667445, 3.7723E-15, 9.08027538, -.25510063, 9.07667445, -.50999047, 9.0658747, -.76445894, 9.04788525,-1.018296, 9.02272129, -1.2712922, 8.99040405, -1.5232392, 8.95096079, -1.7739298, 8.90442474, -2.0231581, 8.85083509, -2.27072, 8.79023691, -2.5164131, 8.72268111, -2.7600372, 8.64822438, -3.0013942, 8.56692911, -3.2402888, 8.47886329, -3.476528, 8.3841005, -3.7099219, 8.28271972, -3.9402835, 8.17480534, -4.1674291, 8.06044696, -4.3911783, 7.93973937, -4.6113542, 7.81278238, -4.8277837, 7.67968076, -5.0402974, 7.54054407, -5.2487296, 7.39548658, -5.4529191, 7.24462711, -5.6527085, 7.08808893, -5.8479446, 6.92599964, -6.0384788, 6.758491, -6.2241667, 6.58569883, -6.4048685, 6.40776286, -6.5804488, 6.22482658, -6.7507769, 6.03703716, -6.9157268, 5.84454523, -7.0751771, 5.64750481, -7.2290111, 5.44607313, -7.377117, 5.24041051, -7.5193876, 5.03068022, -7.6557206, 4.81704835, -7.7860186, 4.59968364, -7.9101888, 4.37875739, -8.02814
33, 4.15444327, -8.1397992, 3.92691724, -8.2450781, 3.69635739, -8.3439067, 3.4629438, -8.4362164, 3.22685841, -8.5219434, 2.9882849, -8.6010286, 2.74740856, -8.6734179, 2.50441616, -8.7390617, 2.2594958, -8.7979155, 2.01283683, -8.8499391, 1.76462967, -8.8950973, 1.51506573, -8.9333597, 1.26433727, -8.9647005, 1.01263726, -8.9890985, .760159289, -9.0065374, .507097431, -9.0170054, .253646111, -9.0204955, 3.7836E-15, -9.0170054, -.25364611, -9.0065374, -.50709743, -8.9890985, -.76015929, -8.9647005, -1.0126373, -8.9333597, -1.2643373, -8.8950973, -1.5150657, -8.8499391, -1.7646297, -8.7979155, -2.0128368, -8.7390617, -2.2594958, -8.6734179, -2.5044162, -8.6010286, -2.7474086, -8.5219434, -2.9882849, -8.4362164, -3.2268584, -8.3439067, -3.4629438, -8.2450781, -3.6963574, -8.1397992, -3.9269172, -8.0281433, -4.1544433, -7.9101888, -4.3787574, -7.7860186, -4.5996836, -7.6557206, -4.8170484, -7.5193876, -5.0306802, -7.377117, -5.2404105, -7.2290111,-5.4460731, -7.0751771, -5.6475048, -6.9157268, -5.8445452, -6.7507769, -6.0370372, -6.5804488, -6.2248266, -6.4048685,-6.4077629, -6.2241667, -6.5856988, -6.0384788, -6.758491, -5.8479446, -6.9259996, -5.6527085, -7.0880889, -5.4529191, -7.2446271, -5.2487296, -7.3954866, -5.0402974, -7.5405441, -4.8277837, -7.6796808, -4.6113542, -7.8127824, -4.3911783, -7.9397394, -4.1674291, -8.060447, -3.9402835, -8.1748053, -3.7099219, -8.2827197, -3.476528, -8.3841005, -3.2402888, -8.4788633, -3.0013942, -8.5669291, -2.7600372, -8.6482244, -2.5164131, -8.7226811, -2.27072, -8.7902369, -2.0231581, -8.8508351, -1.7739298, -8.9044247, -1.5232392, -8.9509608, -1.2712922, -8.9904041, -1.018296, -9.0227213, -.76445894, -9.0478853, -.50999047, -9.0658747, -.25510063, -9.0766745, -5.361E-15, -9.0802754, .255100632, -9.0766745, .509990466, -9.0658747, .764458942, -9.0478853, 1.01829598, -9.0227213, 1.27129222, -8.9904041, 1.52323924, -8.9509608, 1.77392981, -8.9044247, 2.02315813, -8.8508351, 2.27072, -8.7902369, 2.5164131, -8.7226811, 2.76003717, -8.6482244, 3.00139424, -8.5669291, 3.24028879, -8.4788633, 3.476528, -8.3841005, 3.70992187, -8.2827197, 3.94028348, -8.1748053, 4.16742907, -8.060447, 4.39117828, -7.9397394, 4.61135423, -7.8127824, 4.82778372, -7.6796808, 5.04029736, -7.5405441, 5.24872964, -7.3954866, 5.45291911, -7.2446271, 5.65270846, -7.0880889, 5.84794461, -6.9259996, 6.03847881, -6.758491, 6.22416673, -6.5856988, 6.40486849, -6.4077629, 6.5804488, -6.2248266, 6.75077693, -6.0370372, 6.91572682, -5.8445452, 7.0751771, -5.6475048, 7.22901112, -5.4460731, 7.377117, -5.2404105, 7.51938761, -5.0306802, 7.65572064, -4.8170484, 7.78601859, -4.5996836, 7.91018877, -4.3787574, 8.02814331, -4.1544433, 8.13979915, -3.9269172, 8.24507809, -3.6963574, 8.34390671, -3.4629438, 8.43621641, -3.2268584, 8.52194338, -2.9882849, 8.60102862, -2.7474086, 8.6734179, -2.5044162, 8.73906175, -2.2594958, 8.79791545, -2.0128368, 8.84993906, -1.7646297, 8.89509732, -1.5150657, 8.93335973, -1.2643373, 8.96470049, -1.0126373, 8.98909849, -.76015929, 9.00653735, -.50709743, 9.01700535, -.25364611, 9.02049547, -3.718E-15, 9.01700535, .253646111, 9.00653735, .507097431, 8.98909849, .760159289, 8.96470049, 1.01263726, 8.93335973, 1.26433727, 8.89509732, 1.51506573, 8.84993906, 1.76462967, 8.79791545, 2.01283683, 8.73906175, 2.2594958, 8.6734179, 2.50441616, 8.60102862, 2.74740856, 8.52194338, 2.9882849, 8.43621641, 3.22685841, 8.34390671, 3.4629438, 8.24507809, 3.69635739, 8.13979915, 3.92691724, 8.02814331, 4.15444327, 7.91018877, 4.37875739, 7.78601859, 4.59968364, 7.65572064, 4.81704835, 7.51938761, 5.03068022, 7.377117, 5.24041051, 7.22901112, 5.44607313, 7.0751771, 5.64750481, 6.91572682, 5.84454523, 6.75077693, 6.03703716, 6.5804488, 6.22482658, 6.40486849, 6.40776286))
这里缓冲的点坐标为(0,0),缓冲结果是一个由圆弧段构成的多边形,X方向最大值为9.0802754、Y方向最大值为9.0204955——显然,这是一个比较扁的椭圆,而且在X方向最大值(0纬度上的9.0802754度)就是1000千米对应的经度值,这是符合真实结果的。如果直接作为投影坐标进行缓冲的话,结果应该是一个圆形:
SQL> select sdo_geom.sdo_buffer(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0,0, NULL),NULL,NULL),10,0.01) from dual;
SDO_GEOM.SDO_BUFFER(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0,0,NULL),NULL,NULL),10,0.01)(SDO_GTYPE, SDO_SRID, SDO_POINT(X
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 2), SDO_ORDINATE_ARRAY(-8.882E-16, -10, 10, -1.776E-15, -8.882E-16, 10, -10, -1.776E-15, -8.882E-16, -10))
ArcSDE中缓冲分析使用ST_Buffer函数实现,ST_Buffer的函数原型如下:
sde.st_buffer (g1 sde.st_geometry, distance double_precision)
也就是ArcSDE中只需要指定几何对象和缓冲距离即可。为什么ArcSDE不支持投影的缓冲呢?我们要时刻想到ArcSDE仅仅是ArcGIS的空间数据存储方案,复杂的缓冲等几何操作在ArcGIS产品线的其它产品中都有实现,而不像Oracle Spatial必须在数据库上完成这些功能。因此ArcSDE在数据库端实现的空间操作基本只包含OGC规范所包含的内容。
下面是通过ArcSDE进行缓冲的操作:
SQL> select sde.st_astext(sde.st_buffer(sde.st_geomfromtext('POINT(0 0)',0), 10)) from dual;
SDE.ST_ASTEXT(SDE.ST_BUFFER(SDE.ST_GEOMFROMTEXT('POINT(00)',0),10))
--------------------------------------------------------------------------------
POLYGON (( 10.00000000 0.00000000, 9.97858923 0.65403129, 9.91444861 1.30526192, 9.80785280 1.95090322, 9.65925826 2.58819045, 9.46930129 3.21439465, 9.23879533 3.82683432, 8.96872741 4.42288690, 8.66025404 5.00000000, 8.31469612 5.55570233, 7.93353340 6.08761429, 7.51839807 6.59345815, 7.07106781 7.07106781, 6.59345815 7.51839807, 6.08761429 7.93353340, 5.55570233 8.31469612, 5.00000000 8.66025404, 4.42288690 8.96872741, 3.82683432 9.23879533, 3.21439465 9.46930129, 2.58819045 9.65925826, 1.95090322 9.80785280, 1.30526192 9.91444861, 0.65403129 9.97858923, 0.00000000 10.00000000, -0.65403129 9.97858923, -1.30526192 9.91444861, -1.95090322 9.80785280, -2.58819045 9.65925826, -3.21439465 9.46930129, -3.82683432 9.23879533, -4.42288690 8.96872741, -5.00000000 8.66025404, -5.55570233 8.31469612, -6.08761429 7.93353340, -6.59345815 7.51839807, -7.07106781 7.07106781, -7.51839807 6.59345815, -7.93353340 6.08761429, -8.31469612 5.55570233, -8.66025404 5.00000000, -8.96872741 4.42288690, -9.23879533 3.82683432, -9.46930129 3.21439465, -9.65925826 2.58819045, -9.80785280 1.95090322, -9.91444861 1.30526192, -9.97858923 0.65403129, -10.00000000 0.00000000, -9.97858923 -0.65403129, -9.91444861 -1.30526192, -9.80785280 -1.95090322, -9.65925826 -2.58819045, -9.46930129 -3.21439465, -9.23879533 -3.82683432, -8.96872741 -4.42288690, -8.66025404 -5.00000000, -8.31469612-5.55570233, -7.93353340 -6.08761429, -7.51839807 -6.59345815, -7.07106781 -7.07106781, -6.59345815 -7.51839807, -6.08761429 -7.93353340, -5.55570233 -8.31469612, -5.00000000 -8.66025404, -4.42288690 -8.96872741, -3.82683432 -9.23879533, -3.21439465 -9.46930129, -2.58819045 -9.65925826, -1.95090322 -9.80785280, -1.30526192 -9.91444861, -0.65403129 -9.97858923, 0.00000000 -10.00000000, 0.65403129 -9.97858923, 1.30526192 -9.91444861, 1.95090322 -9.80785280, 2.58819045 -9.65925826, 3.21439465 -9.46930129, 3.82683432 -9.23879533, 4.42288690 -8.96872741, 5.00000000 -8.66025404, 5.55570233 -8.31469612, 6.08761429 -7.93353340, 6.59345815 -7.51839807, 7.07106781 -7.07106781,7.51839807 -6.59345815, 7.93353340 -6.08761429, 8.31469612 -5.55570233, 8.66025404 -5.00000000, 8.96872741 -4.42288690, 9.23879533 -3.82683432, 9.46930129 -3.21439465, 9.65925826 -2.58819045, 9.80785280 -1.95090322, 9.91444861 -1.30526192, 9.97858923 -0.65403129, 10.00000000 0.00000000))
Oracle Spatial使用SDO_GEOM包的SDO_DISTANCE函数实现:
SQL> select objectid,sdo_geom.sdo_distance(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0,0, NULL),NULL,NULL),shape,0.01) from sdo_cities where objectid<10;
OBJECTID SDO_GEOM.SDO_DISTANCE(SDO_GEOMETRY(2001,NULL,SDO_POINT_TYPE(0,0,NULL),NULL,NULL),SHAPE,0.01)
---------- --------------------------------------------------------------------------------------------
1 177.441709
2 17.0281416
3 78.4360425
4 75.6184995
5 72.5343637
6 73.3851836
7 74.3064287
8 72.7180626
9 70.5420529
ArcSDE使用ST_Distance函数实现:
SQL> select objectid,sde.st_distance(sde.st_geomfromtext('POINT(0 0)',0),shape) from sde_cities where objectid<10;
OBJECTID SDE.ST_DISTANCE(SDE.ST_GEOMFROMTEXT('POINT(00)',0),SHAPE)
---------- ---------------------------------------------------------
1 177.441709
2 17.0281416
3 78.4360425
4 75.6184995
5 72.5343637
6 73.3851836
7 74.3064287
8 72.7180626
9 70.5420529
Oracle Spatial使用SDO_GEOM包的SDO_AREA和SDO_LENGTH函数实现:
SQL> select objectid,sdo_geom.sdo_area(shape,0.01) from sdo_continent;
OBJECTID SDO_GEOM.SDO_AREA(SHAPE,0.01)
---------- -----------------------------
1 5432.08564
2 3707.41866
3 1444.71727
4 2559.07307
5 1539.3129
6 42.5654563
7 695.539935
8 6034.46185
SQL> select objectid,sdo_geom.sdo_length(shape,0.01) from sdo_continent;
OBJECTID SDO_GEOM.SDO_LENGTH(SHAPE,0.01)
---------- -------------------------------
1 2331.82054
2 3954.89183
3 1598.02862
4 426.208533
5 622.552604
6 221.581977
7 252.165153
8 1587.22795
ArcSDE使用ST_Area和ST_Length函数实现:
SQL> select objectid,sde.st_area(shape) from sde_continent;
OBJECTID SDE.ST_AREA(SHAPE)
---------- ------------------
1 5432.08564
2 3707.41866
3 1444.71727
4 2559.07307
5 1539.3129
6 42.5654563
7 695.539935
8 6034.46185
SQL> select objectid,sde.st_length(shape) from sde_continent;
OBJECTID SDE.ST_LENGTH(SHAPE)
---------- --------------------
1 2331.82054
2 3954.89183
3 1598.02862
4 426.208533
5 622.552604
6 221.581977
7 252.165153
8 1587.22795
Oracle Spatial使用SDO_GEOM包的SDO_CONVEXHULL函数实现:
SQL> select sdo_geom.sdo_convexhull(shape,0.01) from sdo_continent where objectid=1;
SDO_GEOM.SDO_CONVEXHULL(SHAPE,0.01)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(122.848862, -10.929653, 150.209686, -10.700556, 150.426224, -10.689167, 150.880524, -10.652779, 150.8936, -10.648749, 151.229126, -10.201111, 179.604401, 62.7002678, 180, 65.0689087, 180, 65.3986053, 180, 65.9801025, 180, 66.9801025, 180, 67.9801025, 180, 68.9801025, 180, 70.9972076, 180, 71.5358582, 156.722748, 77.1322021, 156.700806, 77.1369324, 156.67746, 77.1405487, 156.653046, 77.1430511,156.603027, 77.1469421, 95.6994171, 81.2902679, 95.6530457, 81.2905426, 95.5274811, 81.2894287, 90.4994202, 81.2263794,90.1691437, 81.2188721, 79.6588745, 80.9788666, -179.6286, 71.5771942, -179.90077, 71.54879, -180, 71.5358429, -180, 70.9972076, -180, 68.9801025, -180, 68.0689087, -180, 67.0689087, -180, 66.0689087, -180, 65.0689087, 72.4325409, -7.4347382, 72.4381714, -7.4362497, 105.701401, -10.51097, 122.848862, -10.929653))
ArcSDE使用ST_ConvexHull函数实现:
SQL> select sde.st_astext(sde.st_convexhull(shape)) from sde_continent where objectid=1;
SDE.ST_ASTEXT(SDE.ST_CONVEXHULL(SHAPE))
--------------------------------------------------------------------------------
POLYGON (( -180.00000000 71.53584290, -180.00000000 70.99720764, -180.00000000 68.98010254, -180.00000000 68.06890869, -180.00000000 67.06890869, -180.00000000 66.06890869, -180.00000000 65.06890869, 72.43254089 -7.43473816, 72.43817139 -7.43624973, 105.70140076 -10.51097012, 122.84886169 -10.92965317, 150.20968628 -10.70055580, 150.42622376 -10.68916702, 150.88052368 -10.65277862, 150.89360046 -10.64874935, 151.22912598 -10.20111084, 179.60440064 62.70026779, 180.00000000 65.06890869, 180.00000000 65.39860535, 180.00000000 65.98010254, 180.00000000 66.98010254, 180.00000000 67.98010254, 180.00000000 68.98010254, 180.00000000 70.99720764, 180.00000000 71.53585815, 156.72274780 77.13220215, 156.70080566 77.13693237, 156.67745972 77.14054871, 156.65304565 77.14305115, 156.60302734 77.14694214, 95.69941711 81.29026794, 95.65304565 81.29054260, 95.52748108 81.28942871, 90.49942017 81.22637939, 90.16914368 81.21887207, 79.65887451 80.97886658, -179.62860107 71.57719421, -179.90077210 71.54878998, -180.00000000 71.53584290))
几何对象的组合大体上有以下几种:
几何对象组合 |
描述(灰色部分为结果) |
Intersecion |
|
Difference |
|
Union |
|
Xor/SymmetricDiff |
Oracle Spatial中的操作:
SQL> select sdo_geom.sdo_intersection(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(1,1,3,1,3,3,1,3,1,1)),1) from dual;
SDO_GEOM.SDO_INTERSECTION(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(1, 2, 1, 1, 2, 1, 2, 2, 1, 2))
SQL> select sdo_geom.sdo_difference(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(1,1,3,1,3,3,1,3,1,1)),1) from dual;
SDO_GEOM.SDO_DIFFERENCE(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(0, 2, 0, 0, 2, 0, 2, 1, 1, 1, 1, 2, 0, 2))
SQL> select sdo_geom.sdo_union(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(1,1,3,1,3,3,1,3,1,1)),1) from dual;
SDO_GEOM.SDO_UNION(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SD
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(2, 1, 3, 1, 3, 3, 1, 3, 1, 2, 0, 2, 0, 0, 2, 0, 2, 1))
SQL> select sdo_geom.sdo_xor(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(1,1,3,1,3,3,1,3,1,1)),1) from dual;
SDO_GEOM.SDO_XOR(SDO_GEOMETRY(2003,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(0,0,2,0,2,2,0,2,0,0)),SDO_
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 15, 1003, 1), SDO_ORDINATE_ARRAY(3, 3, 1, 3, 1, 2, 2, 2,2, 1, 3, 1, 3, 3, 0, 2, 0, 0, 2, 0, 2, 1, 1, 1, 1, 2, 0, 2))
ArcSDE中的操作:
SQL> select sde.st_astext(sde.st_intersection(sde.st_geometry('POLYGON((0 0,2 0,2 2,0 2,0 0))',0),sde.st_geometry('POLYGON((1 1,3 1,3 3,1 3,1 1))',0))) from dual;
SDE.ST_ASTEXT(SDE.ST_INTERSECTION(SDE.ST_GEOMETRY('POLYGON((00,20,22,02,00))',0)
--------------------------------------------------------------------------------
POLYGON (( 1.00000000 1.00000000, 2.00000000 1.00000000, 2.00000000 2.0000000
0, 1.00000000 2.00000000, 1.00000000 1.00000000))
SQL> select sde.st_astext(sde.st_difference(sde.st_geometry('POLYGON((0 0,2 0,2 2,0 2,0 0))',0),sde.st_geometry('POLYGON((1 1,3 1,3 3,1 3,1 1))',0))) from dual;
SDE.ST_ASTEXT(SDE.ST_DIFFERENCE(SDE.ST_GEOMETRY('POLYGON((00,20,22,02,00))',0),S
--------------------------------------------------------------------------------
POLYGON (( 0.00000000 0.00000000, 2.00000000 0.00000000, 2.00000000 1.00000000, 1.00000000 1.00000000, 1.00000000 2.00000000, 0.00000000 2.00000000, 0.00000000 0.00000000))
SQL> select sde.st_astext(sde.st_union(sde.st_geometry('POLYGON((0 0,2 0,2 2,0 2,0 0))',0),sde.st_geometry('POLYGON((1 1,3 1,3 3,1 3,1 1))',0))) from dual;
SDE.ST_ASTEXT(SDE.ST_UNION(SDE.ST_GEOMETRY('POLYGON((00,20,22,02,00))',0),SDE.ST
--------------------------------------------------------------------------------
POLYGON (( 0.00000000 0.00000000, 2.00000000 0.00000000, 2.00000000 1.00000000, 3.00000000 1.00000000, 3.00000000 3.00000000, 1.00000000 3.00000000, 1.00000000 2.00000000, 0.00000000 2.00000000, 0.00000000 0.00000000))
SQL> select sde.st_astext(sde.st_symmetricdiff(sde.st_geometry('POLYGON((0 0,2 0,2 2,0 2,0 0))',0),sde.st_geometry('POLYGON((1 1,3 1,3 3,1 3,1 1))',0))) from dual;
SDE.ST_ASTEXT(SDE.ST_SYMMETRICDIFF(SDE.ST_GEOMETRY('POLYGON((00,20,22,02,00))',0
--------------------------------------------------------------------------------
MULTIPOLYGON ((( 1.00000000 2.00000000, 2.00000000 2.00000000, 2.00000000 1.00000000, 3.00000000 1.00000000, 3.00000000 3.00000000, 1.00000000 3.00000000, 1.00000000 2.00000000)),(( 0.00000000 0.00000000, 2.00000000 0.00000000, 2.00000000 1.00000000, 1.00000000 1.00000000, 1.000000002.00000000, 0.00000000 2.00000000, 0.00000000 0.00000000)))
Oracle Spatial有SDO_AGGR_CONVEXHULL和SDO_AGGR_UNION函数实现聚合:
SQL> select sdo_aggr_convexhull(SDOAGGRTYPE(shape, 0.1)) from sdo_cities where objectid<10;
SDO_AGGR_CONVEXHULL(SDOAGGRTYPE(SHAPE,0.1))(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(-3.0099955, 16.7599981, 55.1070006, 51.7820041, 56.0960016, 54.8219971, 47.2500006, 56.1500011, -165.27, 64.5862861, -3.0099955, 16.7599981))
SQL> select sdo_aggr_union(SDOAGGRTYPE(shape, 0.1)) from sdo_cities where objectid<10;
SDO_AGGR_UNION(SDOAGGRTYPE(SHAPE,0.1))(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
------------------------------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2005, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 9), SDO_ORDINATE_ARRAY(45.1670046, 54.1860031, 48.3620046, 54.3050011, 49.1454636, 55.7330131, 47.2500006, 56.1500011, 51.3559986, 51.2229961, 55.1070006, 51.7820041, 56.0960016, 54.8219971, -3.0099955, 16.7599981, -165.27, 64.5862861))
ArcSDE有ST_Aggr_ConvexHull、ST_Aggr_Union、ST_Aggr_Intersection函数实现聚合,不过经过我的测试,ST_Aggr_ConvexHull函数有点问题,对点进行凸包聚合运算结果不正确,这个函数不应被使用,如果有这样的需求可以通过ST_ConvexHull(ST_Aggr_Union(g st_geometry))这样的方法实现:
SQL> select sde.st_astext(sde.st_convexhull(sde.st_aggr_union(shape))) from sde_cities where objectid<10;
SDE.ST_ASTEXT(SDE.ST_CONVEXHULL(SDE.ST_AGGR_UNION(SHAPE)))
--------------------------------------------------------------------------------
POLYGON (( -165.26999663 64.58628611, -3.00999547 16.75999807, 55.10700058 51.78200410, 56.09600158 54.82199710, 47.25000057 56.15000110, -165.26999663 64.58628611))
SQL> select sde.st_astext(sde.st_aggr_union(shape)) from sde_cities where objectid<10;
SDE.ST_ASTEXT(SDE.ST_AGGR_UNION(SHAPE))
--------------------------------------------------------------------------------
MULTIPOINT ( -165.26999663 64.58628611, -3.00999547 16.75999807, 45.1670045754.18600310, 47.25000057 56.15000110, 48.36200457 54.30500110, 49.14546357 55.73301310, 51.35599858 51.22299610, 55.10700058 51.78200410, 56.09600158 54.82199710)
从结果上可以看到,对一个点数据的部分点进行Aggr_Union运算的结果会是一个多点,而Aggr_ConvexHull运算的结果则是一个多边形。Aggr_ConvexHull相当于先执行Aggr_Union运算后再对合并后的几何对象进行ConvexHull运算。
图 14 聚合(Aggr_ConvexHull和Aggr_Union)运算结果