Oracle Spatial 例項簡介

2021-05-01 12:53:35 字數 1701 閱讀 3245

oracle spatial 例項簡介

oracle spatial 簡介:

首先,oracle 支援自定義的資料型別,你可以用陣列,結構體或者帶有建構函式,功能函式的類來定義自己的物件型別。這樣的物件型別可以用於屬性列的資料型別,也可以用來建立物件表。而oracle spatial也正是基於此種特性所開發的一套空間資料處理系統。

spatial 的自定義資料型別有很多,都在mdsys方案下,經常使用的是sdo_geometry型別。sdo_geometry表示乙個幾何物件,可以是點、線、面、多點、多線、多面或混合物件。

spatial 在此資料型別的基礎上,實現了r樹空間索引和四叉樹空間索引,還以sql函式的形式實現了多種空間分析功能。

oracle spatial 使用:

1、將sdo_geometry資料型別作為資料表的乙個列。

create table cola_markets (

mkt_id number primary key,

name varchar2(32),

shape mdsys.sdo_geometry); 2、

填寫空間元資料。

insert into user_sdo_geom_metadata

values (

'cola_markets',

'shape',

mdsys.sdo_dim_array( -- 20x20 grid

mdsys.sdo_dim_element('x', 0, 20, 0.005),

mdsys.sdo_dim_element('y', 0, 20, 0.005) ),

null -- srid

字串4);

3、建立空間索引。

create index cola_spatial_idx

on cola_markets(shape)

indextype is mdsys.spatial_index;

至此,空間資料表的建立才算正式完成 。

4、插入空間資料。空間資料的插入要

insert into cola_markets values( 2,

'cola_b',

mdsys.sdo_geometry(

2003, -- 2-dimensional polygon

null,

null,

mdsys.sdo_elem_info_array(1,1003,1), -- one polygon (exterior polygon ring)

mdsys.sdo_ordinate_array(5,1, 8,1, 8,6, 5,7, 5,1) )

);5、空間分析查詢示例。

-- return the topological difference of two geometries.

select sdo_geom.sdo_difference(c_a.shape, m.diminfo, c_c.shape, m.diminfo)

from cola_markets c_a, cola_markets c_c, user_sdo_geom_metadata m

where m.table_name = 'cola_markets' and m.column_name = 'shape'

and c_a.name = 'cola_a' and c_c.name = 'cola_c';

oracle spatial空間型別建立

oracle spatial空間型別建立 使用oracle11g建立空間表資料,基於oracle spatial的儲存方式,通過這種儲存方式的幾何列shape的字段型別為mdsys.sdo geometry型別,個人覺得關於操作空間資料的sql語句來說,相交於postgresql ms sqlser...

Oracle spatial空間查詢的選擇度分析

接下來,我們來研究一下這個問題。建立表,並使用sdo geometry資料型別儲存向量資料。檢視表中記錄數 建立空間索引 create index tddcsde a3010 ix1 on tddcsde dltb20150705 shape indextype is mdsys spatial i...

Oracle Spatial 幾何物件之間的距離

sdo within distance 操作符是最簡單的空間操作符之一,可以用它來進行臨近分析,查詢時該操作符能夠使用空間索引,加快查詢速度。如給定乙個位置集,該操作符將從中返回在乙個查詢位置指定距離範圍內的所有位置。上圖查詢了距位置q距離為d的所有點,於是物件a,b,c被檢索出來,d,e被排除。操...