Introduction to Oracle Spatial

Source: Internet
Author: User

 

Introduction to Oracle Spatial:
First, Oracle supports custom data types. You can use arrays, struct, or classes with constructors and functions to define your own object types. Such an object type can be used for the Data Type of attribute columns, or for creating an object table. Oracle Spatial is a spatial data processing system developed based on this feature.
There are many Custom Data Types of spatial, which are often used in the MDSYS scheme of sdo_geometry. Sdo_geometry indicates a geometric object, which can be a point, line, plane, multi-point, multi-line, multi-faceted or hybrid object.
Based on this data type, spatial implements the R-tree spatial index and quad-tree spatial index, and implements multiple spatial analysis functions in the form of SQL functions.

Oracle spatial usage:
1. Use the sdo_geometry data type as a column in the data table.

Create Table cola_markets (
Mkt_id number primary key,
Name varchar2 (32 ),
Shape MDSYS. sdo_geometry );

2. Enter the spatial metadata.

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
);

3. Create a spatial index.

Create index cola_spatial_idx
On cola_markets (SHAPE)
Indextype is MDSYS. spatial_index;

Now, the creation of the spatial data table is complete.

4. insert space data. To insert Spatial Data

Insert into cola_markets values (
2,
'Cola _ B ',
MDSYS. sdo_geometry (
2003, -- 2-dimen1_polygon
Null,
Null,
MDSYS. sdo_elem_info_array (1,1003, 1), -- one polygon (exterior polygon ring)
MDSYS. sdo_ordinate_array (5, 1, 8, 8, 6, 5, 7, 5, 1)
)
);

5. Spatial Analysis query example.

-- 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 ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.