You are on page 1of 18

2

Indexing Spatial Data

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


Objectives

After completing this lesson, you should


be able to do the following:

• Explain the concept of spatial indexing


• Explain the difference between Quadtree
and R-tree index

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -2
Spatial Indexing

• There are two methods for indexing


spatial data:
– Quadtree Indexing
– Successive decomposition of space into
tiles
– Two types of quadtree indexes:
– Fixed
– Hybrid (not recommended)
– R-tree indexing
– Based on minimum bounding rectangles
Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -3
Quadtree Indexing

• Based on the successive decomposition


of a coordinate space by factors of 4
– This decomposition is called tessellation
– The results of the tessellation process are
stored in the spatial index
– The tessellation process is performed by
creating the spatial index
– The process of indexing spatial data using
quadtree indexes is called tessellation

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -4
Tessellation

Fixed Tile Decomposition

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -5
How a Geometry is Indexed Using
Quadtree Indexing
• DBA
Determines
– Level = 3

SDO_CODE
FIXED_TILE1
FIXED_TILE2

FIXED_TILE16
Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -6
Primary Filter Example
(Quadtree Index)

sdo_level = 2

• Compares fixed sized tiles that approximate the


area of interest with fixed sized tiles that
approximate each geometry
• Result is not exact because comparing
approximations
A look at Quadtree index structures

create index STATES_GEOM on STATES (GEOM)


indextype is MDSYS.SPATIAL_INDEX
parameters ('SDO_LEVEL=6');

Index Index
STATES_GEOM_FL6$_B1 STATES_GEOM_FL6$_B2

SDO_CODE SDO_ROWID
SDO_ROWID
SDO_STATUS

Table STATES_GEOM_FL6$

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -8
How much of my Quadtree index has
been built?
• Can get information if using SDO_COMMIT_INTERVAL
• Use plain SQL queries on the spatial index table
• First get the name of the index table
• Then get the count of the geometries that have been
indexed
SQL> select sdo_index_table
2 from user_sdo_index_metadata
3 where sdo_index_name = 'STATES_SIDX';

SDO_INDEX_TABLE
--------------------------------
STATES_SIDX_FL8$

SQL> select count (distinct (sdo_rowid))


2 from STATES_SIDX_FL8$;
Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -9
What happens during Quadtree index
creation
• Create the index table
• Populate the index table
– Read the geometries, perform the
tesselation and insert into the index
table
• Create the btree index on tile codes, rowids
and status
• Create the btree index on rowids

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -10
R-tree Indexing
• Another common way to index multi-dimensional
data
• Requires less tuning
• Extends primary filter to 3 or 4 dimensions
• Each index entry approximates geometry using
MBR (Minimum Bounding Rectangle) for 2D, and
MBV (Minimum Bounding Volume) for 3D
• MBRs indexed internally using a tree structure

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -11
R-tree Indexing Concept

R-tree
Index

Leaf nodes of R-tree store


MBR
<MBR, geometry
Geometry pointer>

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -12
How Geometries are Indexed Using
R-trees

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -13
How Geometries are Indexed Using
R-trees (cont.)

R-tree
a
root
R b
R S

d a b c d
S
c root
Pointers to geometries

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -14
Primary Filter Example
(R-tree Index)

• Compares MBR that approximates the area of


interest with the MBR that approximates each
geometry
• Result is not exact because comparing
approximations
Quadtrees or Rtrees ?

• Benchmarking in progress to determine which


indexes are best in which conditions
– Density of data ?
– Uniform distribution ?
– Size of geometries ?
– Alignment of geometries ?

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -16
Quadtrees or R-trees ? (cont.)
• R-trees
– Easier to create
– Nearest neighbor
– Less storage
– If lots of updates may become unstable (can
rebuild)
– Extends primary filter to 3 or 4 dimensions
• Quadtrees
– Requires tuning
– Updates have less effect
– More optimizations
Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -17
Summary

In this lesson, you have learned about:


• The concept of spatial indexing
• The difference between Quadtree and R-tree
index

Copyright  Intergraph Hong Kong Limited, ®

Oracle Corporation, 2002. All rights reserved.


2 -18

You might also like