Oracle® Spatial
User’s Guide and Reference
10g Release 2 (10.2)
B14255-01
June 2005
Provides usage and reference information for indexing and
storing spatial data and for developing spatial applications
using Oracle Spatial and Oracle Locator.
Oracle Spatial User’s Guide and Reference, 10g Release 2 (10.2)
B14255-01
Copyright © 1999, 2005, Oracle. All rights reserved.
Primary Author: Chuck Murray
Contributors: Dan Abugov, Nicole Alexander, Bruce Blackwell, Janet Blowney, Dan Geringer, Albert
Godfrind, Mike Horhammer, Ravi Kothuri, Richard Pitts, Vishal Rao, Siva Ravada, Jack Wang, Ji Yang
The Programs (which include both the software and documentation) contain proprietary information; they
are provided under a license agreement containing restrictions on use and disclosure and are also protected
by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly,
or decompilation of the Programs, except to the extent required to obtain interoperability with other
independently created software or as specified by law, is prohibited.
The information contained in this document is subject to change without notice. If you find any problems in
the documentation, please report them to us in writing. This document is not warranted to be error-free.
Except as may be expressly permitted in your license agreement for these Programs, no part of these
Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose.
If the Programs are delivered to the United States Government or anyone licensing or using the Programs on
behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data
delivered to U.S. Government customers are "commercial computer software" or "commercial technical data"
pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As
such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation
and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license
agreement, and, to the extent applicable, the additional rights set forth in FAR 52.227-19, Commercial
Computer Software—Restricted Rights (June 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City,
CA 94065
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently
dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup,
redundancy and other measures to ensure the safe use of such applications if the Programs are used for such
purposes, and we disclaim liability for any damages caused by such use of the Programs.
Oracle, JD Edwards, PeopleSoft, and Retek are registered trademarks of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
The Programs may provide links to Web sites and access to content, products, and services from third
parties. Oracle is not responsible for the availability of, or any content provided on, third-party Web sites.
You bear all risks associated with the use of such content. If you choose to purchase any products or services
from a third party, the relationship is directly between you and the third party. Oracle is not responsible for:
(a) the quality of third-party products or services; or (b) fulfilling any of the terms of the agreement with the
third party, including delivery of products or services and warranty obligations related to purchased
products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from
dealing with any third party.
iii
Contents
Send Us Your Comments ...................................................................................................................... xix
Preface ............................................................................................................................................................... xxi
Audience..................................................................................................................................................... xxi
Documentation Accessibility.................................................................................................................. xxii
Organization ............................................................................................................................................. xxii
Technologies Released Separately ........................................................................................................ xxiv
Related Documentation.......................................................................................................................... xxiv
Conventions ............................................................................................................................................. xxv
What’s New in Oracle Spatial?......................................................................................................... xxvii
Coordinate System Support Based on EPSG Model ......................................................................... xxvii
New SDO_GEOMETRY Methods and Constructors....................................................................... xxviii
New min_resolution and max_resolution Keywords...................................................................... xxviii
New sdo_dml_batch_size Parameter ................................................................................................... xxix
New Geocoding Subprograms.............................................................................................................. xxix
New Utility Subprograms...................................................................................................................... xxix
U.S. National Grid Support.................................................................................................................... xxx
Unknown and NaC Coordinate Reference Systems .......................................................................... xxx
Spatial Routing Engine........................................................................................................................... xxx
Part I Conceptual and Usage Information
1 Spatial Concepts
1.1 What Is Oracle Spatial? .............................................................................................................. 1-2
1.2 Object-Relational Model ............................................................................................................ 1-2
1.3 Introduction to Spatial Data ...................................................................................................... 1-3
1.4 Geometry Types.......................................................................................................................... 1-3
1.5 Data Model................................................................................................................................... 1-4
1.5.1 Element.................................................................................................................................. 1-4
1.5.2 Geometry............................................................................................................................... 1-5
1.5.3 Layer...................................................................................................................................... 1-5
1.5.4 Coordinate System............................................................................................................... 1-5
1.5.5 Tolerance............................................................................................................................... 1-6
1.5.5.1 Tolerance in the Geometry Metadata for a Layer.................................................... 1-7
iv
1.5.5.2 Tolerance as an Input Parameter................................................................................ 1-7
1.6 Query Model................................................................................................................................ 1-8
1.7 Indexing of Spatial Data............................................................................................................. 1-9
1.7.1 R-Tree Indexing.................................................................................................................... 1-9
1.7.2 R-Tree Quality................................................................................................................... 1-10
1.8 Spatial Relationships and Filtering ....................................................................................... 1-11
1.9 Spatial Operators, Procedures, and Functions .................................................................... 1-13
1.10 Spatial Aggregate Functions .................................................................................................. 1-14
1.10.1 SDOAGGRTYPE Object Type......................................................................................... 1-14
1.11 Geocoding ................................................................................................................................. 1-15
1.12 Spatial Java Application Programming Interface ............................................................... 1-15
1.13 MDDATA Schema ................................................................................................................... 1-16
1.14 Performance and Tuning Information.................................................................................. 1-16
1.15 Open Geospatial Consortium (OGC) Conformance........................................................... 1-16
1.16 Spatial Release (Version) Number......................................................................................... 1-16
1.17 Spatial Application Hardware Requirement Considerations ........................................... 1-17
1.18 Spatial Error Messages............................................................................................................ 1-17
1.19 Spatial Examples ...................................................................................................................... 1-17
1.20 README File for Spatial and Related Features.................................................................. 1-18
2 Spatial Data Types and Metadata
2.1 Simple Example: Inserting, Indexing, and Querying Spatial Data...................................... 2-1
2.2 SDO_GEOMETRY Object Type ................................................................................................ 2-5
2.2.1 SDO_GTYPE......................................................................................................................... 2-5
2.2.2 SDO_SRID............................................................................................................................. 2-7
2.2.3 SDO_POINT ......................................................................................................................... 2-7
2.2.4 SDO_ELEM_INFO............................................................................................................... 2-7
2.2.5 SDO_ORDINATES ........................................................................................................... 2-10
2.2.6 Usage Considerations ...................................................................................................... 2-11
2.3 SDO_GEOMETRY Methods................................................................................................... 2-11
2.4 SDO_GEOMETRY Constructors............................................................................................ 2-13
2.5 Geometry Examples................................................................................................................. 2-14
2.5.1 Rectangle............................................................................................................................ 2-14
2.5.2 Polygon with a Hole......................................................................................................... 2-15
2.5.3 Compound Line String .................................................................................................... 2-17
2.5.4 Compound Polygon ......................................................................................................... 2-19
2.5.5 Point.................................................................................................................................... 2-20
2.5.6 Oriented Point................................................................................................................... 2-21
2.5.7 Type 0 (Zero) Element...................................................................................................... 2-23
2.5.8 Several Geometry Types.................................................................................................. 2-25
2.6 Geometry Metadata Views..................................................................................................... 2-29
2.6.1 TABLE_NAME.................................................................................................................. 2-30
2.6.2 COLUMN_NAME............................................................................................................ 2-30
2.6.3 DIMINFO........................................................................................................................... 2-30
2.6.4 SRID.................................................................................................................................... 2-31
2.7 Spatial Index-Related Structures ........................................................................................... 2-31
2.7.1 Spatial Index Views.......................................................................................................... 2-31
v
2.7.1.1 xxx_SDO_INDEX_INFO Views............................................................................... 2-31
2.7.1.2 xxx_SDO_INDEX_METADATA Views................................................................. 2-32
2.7.2 Spatial Index Table Definition ........................................................................................ 2-34
2.7.3 R-Tree Index Sequence Object ........................................................................................ 2-34
2.8 Unit of Measurement Support ............................................................................................... 2-35
3 Loading Spatial Data
3.1 Bulk Loading .............................................................................................................................. 3-1
3.1.1 Bulk Loading SDO_GEOMETRY Objects ........................................................................ 3-1
3.1.2 Bulk Loading Point-Only Data in SDO_GEOMETRY Objects...................................... 3-3
3.2 Transactional Insert Operations Using SQL ........................................................................... 3-3
4 Indexing and Querying Spatial Data
4.1 Creating a Spatial Index............................................................................................................. 4-1
4.1.1 Indexing Geodetic Data ...................................................................................................... 4-2
4.1.2 Constraining Data to a Geometry Type............................................................................ 4-2
4.1.3 Creating a Cross-Schema Index......................................................................................... 4-3
4.1.4 Using Partitioned Spatial Indexes..................................................................................... 4-3
4.1.5 Exchanging Partitions Including Indexes ........................................................................ 4-5
4.1.6 Export and Import Considerations with Spatial Indexes and Data ............................. 4-5
4.2 Querying Spatial Data................................................................................................................ 4-6
4.2.1 Spatial Query........................................................................................................................ 4-6
4.2.1.1 Primary Filter Operator............................................................................................... 4-7
4.2.1.2 Primary and Secondary Filter Operator.................................................................... 4-8
4.2.1.3 Within-Distance Operator........................................................................................... 4-9
4.2.1.4 Nearest Neighbor Operator ..................................................................................... 4-10
4.2.1.5 Spatial Functions........................................................................................................ 4-11
4.2.2 Spatial Join ......................................................................................................................... 4-11
4.2.3 Cross-Schema Operator Invocation ............................................................................... 4-12
5 Geocoding Address Data
5.1 Concepts for Geocoding............................................................................................................. 5-1
5.1.1 Address Representation...................................................................................................... 5-1
5.1.2 Match Modes........................................................................................................................ 5-2
5.1.3 Match Codes......................................................................................................................... 5-3
5.1.4 Error Messages for Output Geocoded Addresses .......................................................... 5-4
5.2 Data Types for Geocoding......................................................................................................... 5-4
5.2.1 SDO_GEO_ADDR Type ..................................................................................................... 5-4
5.2.2 SDO_ADDR_ARRAY Type................................................................................................ 5-7
5.2.3 SDO_KEYWORDARRAY Type......................................................................................... 5-7
5.3 Using the Geocoding Capabilities............................................................................................ 5-7
5.4 Geocoding from a Place Name.................................................................................................. 5-8
5.5 Data Structures for Geocoding.................................................................................................. 5-9
5.5.1 GC_AREA_<suffix> Table .............................................................................................. 5-10
5.5.2 GC_COUNTRY_PROFILE Table.................................................................................... 5-11
5.5.3 GC_INTERSECTION_<suffix> Table............................................................................ 5-13