spatial information systems (sis) comp 30110 spatial access methods: indexing
Post on 20-Dec-2015
223 views
TRANSCRIPT
Spatial Information Systems (SIS)Spatial Information Systems (SIS)
COMP 30110COMP 30110
Spatial access methods:Spatial access methods:
IndexingIndexing
In previous lecturesIn previous lectures• Oracle SpatialOracle Spatial
• Object-relational modelObject-relational model
• SDO_Geometry data typeSDO_Geometry data type
• Spatial functionality and Query modelSpatial functionality and Query model
TodayToday• Indexing Spatial DataIndexing Spatial Data
• Indexing mechanisms in Oracle SpatialIndexing mechanisms in Oracle Spatial
• R-treesR-trees
Spatial IndexesSpatial Indexes
Used to speed up spatial queriesUsed to speed up spatial queries
ExampleExample: :
Point queryPoint query: return the geometric object that contains a : return the geometric object that contains a given query pointgiven query point
Sequentially scanning all objects of a large collection to Sequentially scanning all objects of a large collection to check whether they contain the query point involves a check whether they contain the query point involves a high number of disk accesses and the repetition of the high number of disk accesses and the repetition of the evaluation of computationally expensive geometric evaluation of computationally expensive geometric predicates (e.g., containment, intersection, etc.)predicates (e.g., containment, intersection, etc.)
Reducing the set of objects to be processed is highly Reducing the set of objects to be processed is highly desirabledesirable
Indexes for object-based and Indexes for object-based and space-based representationsspace-based representations
Indexes for raster dataIndexes for raster data: :
based on recursive subdivision of the spacebased on recursive subdivision of the space
ExampleExample: quadtrees: quadtrees
Indexes for vector dataIndexes for vector data: :
differ depending on the type of datadiffer depending on the type of data
(extensions of quadtrees are used also for vector data)(extensions of quadtrees are used also for vector data)
Vector Data IndexingVector Data Indexing
• Different indexing methods are used for point, linear Different indexing methods are used for point, linear and polygonal dataand polygonal data
• In the case of collections of polygons, instead of In the case of collections of polygons, instead of indexing the object geometries themselves, whose indexing the object geometries themselves, whose shapes might be complex, we consider an shapes might be complex, we consider an approximation of the geometry and index it insteadapproximation of the geometry and index it instead
• Most commonly used approximation: Most commonly used approximation: minimum minimum bounding rectanglebounding rectangle (MBR) (MBR) also called also called minimum minimum bounding boxbounding box (MBB) (MBB)
MBRsMBRs
• By using the MBR as the geometric key for building the By using the MBR as the geometric key for building the spatial index, we save the cost of evaluating expensive spatial index, we save the cost of evaluating expensive geometric predicates during index traversal (as geometric predicates during index traversal (as geometric tests againsts an MBR is constant)geometric tests againsts an MBR is constant)
• ExampleExample: point-in-polygon test : point-in-polygon test
• In addition, the space required to store a rectangle is In addition, the space required to store a rectangle is constant (2 points)constant (2 points)
(x,y) (x,y)
MBRs (cont.d)MBRs (cont.d)
An operation involving a spatial predicate on a An operation involving a spatial predicate on a collection of objects indexed on their MBRs is collection of objects indexed on their MBRs is performed in two steps:performed in two steps:
1.1. Filter step: Filter step: selects the objects whose MBR satisfies the selects the objects whose MBR satisfies the spatial predicate (by traversing the spatial index and spatial predicate (by traversing the spatial index and applying the predicate to the MBRs)applying the predicate to the MBRs)
2.2. Refinement step: Refinement step: the objects that pass the filter step are a the objects that pass the filter step are a superset of the solution. An MBR might satisfy the predicate superset of the solution. An MBR might satisfy the predicate but the corresponding object might notbut the corresponding object might not
obj
MBRPP
Refinement step: Refinement step: the objects that pass the filter step the objects that pass the filter step are a superset of the solution. An MBR might satisfy are a superset of the solution. An MBR might satisfy the predicate but the corresponding object might notthe predicate but the corresponding object might not
Therefore, in this step the spatial predicate is applied Therefore, in this step the spatial predicate is applied to the actual geometry of the objectto the actual geometry of the object
obj
MBRPP
Refinement stepRefinement step
Oracle Spatial Oracle Spatial Query ModelQuery Model
Spatial LayerData
Table wherecoordinates are stored
PrimaryFilter
Spatial Index
Index retrieves area of interest
ReducedData Set
SecondaryFilter
SpatialFunctions
Proceduresthat determineexact relationship
ExactResult
Set
Oracle Spatial Indexing Oracle Spatial Indexing MethodsMethods
Two types of indexes are implemented in Oracle Spatial: Two types of indexes are implemented in Oracle Spatial:
• R-treesR-trees
• QuadtreesQuadtrees
R-treesR-trees
Based on Based on MBRMBRss (minimum bounding rectangle (minimum bounding rectangless))
Defined for indexing 2D objects (can be extended to higher Defined for indexing 2D objects (can be extended to higher dimensions but implemented only for 2D in Oracle Spatial)dimensions but implemented only for 2D in Oracle Spatial)
MBRs of geometric objects MBRs of geometric objects form the leaves of the index treeform the leaves of the index tree
MultipleMultiple MBRs MBRs are grouped are grouped into larger rectanglesinto larger rectangles (MBRs) to (MBRs) to form intermediate nodes in the treeform intermediate nodes in the tree
Repeat until one rectangle is left that contains everythingRepeat until one rectangle is left that contains everything
R-treesR-trees
a
b
c
d a b c d
R
S
R S
root
root
R-tree1
2 3
4
56
7
8
9
Pointers to geometries
4 5 6 7 8 91 2 3
Remark: nodesRemark: nodes
• Intermediate nodes store:Intermediate nodes store:
MBRs of MBRs of collectionscollections of objects of objects
• Leaf nodes store:Leaf nodes store:
MBRs of individual objectsMBRs of individual objects
Pointers to storage location of the exact geometryPointers to storage location of the exact geometry
Building R-treesBuilding R-trees
An R-tree is a depth-balanced tree in which each node An R-tree is a depth-balanced tree in which each node corresponds to a disk page (i.e., the number of entries in corresponds to a disk page (i.e., the number of entries in each node is limited)each node is limited)
The structure satisfies the following properties:The structure satisfies the following properties:
1.1. For all nodes in the tree (except the root) the number of For all nodes in the tree (except the root) the number of entries is between entries is between mm and and MM
2.2. The root has at least two children (unless it is a leaf)The root has at least two children (unless it is a leaf)
3.3. All leaves are at the same levelAll leaves are at the same level
Example (1)Example (1)
a
b
c
d a b c d
R
S
R S
root
root
R-tree1
2 3
4
56
7
8
9
Pointers to geometries
4 5 6 7 8 91 2 3
m m = 2; = 2; M M = 3= 3
Example (2)Example (2)
m m = 2; = 2; M M = 4= 4
R-tree
R1 R3
root
R2
….. ….. …..
Searching R-treesSearching R-trees
We consider two types of queries:We consider two types of queries:
1.1. point querypoint query: “what object contains the query : “what object contains the query point”point”
2.2. window querywindow query: “what objects intersect the query : “what objects intersect the query window”window”
Basic spatial queries (1)Basic spatial queries (1)
Containment QueryContainment Query: Given a spatial object : Given a spatial object OO, find all , find all objects in the collection that completely contain objects in the collection that completely contain O.O. When When OO is a point, the query is called is a point, the query is called Point QueryPoint Query
O
P
Containment Query Point Query
(also Point-in-polygon, or Point Location)
Basic spatial queries (2)Basic spatial queries (2)
Region QueryRegion Query: Given a region : Given a region RR, find all objects in the , find all objects in the collection that intersect collection that intersect R.R. When When RR is a rectangle, the is a rectangle, the query is called query is called Window QueryWindow Query
R R
Region Query Window Query
Searching R-trees: window querySearching R-trees: window query
Compare search window with MBRs stored at each nodeCompare search window with MBRs stored at each nodestarting at root nodestarting at root node
Stop at leaf nodesStop at leaf nodescompare contained geometries with search windowcompare contained geometries with search window
5
Searching R-trees: window querySearching R-trees: window query
Example:Example:
a b c d
R S
root
R-tree1
2 3
4
6
7
8
9
4 8 91 2 3
a
b
c
d
root
R
S
Pointers to geometries
Example: remarksExample: remarks
If no MBRs are used: check the query window against all If no MBRs are used: check the query window against all geometries for intersection (computationally expensive)geometries for intersection (computationally expensive)
In some cases, using R-trees to structure the set of MBRs In some cases, using R-trees to structure the set of MBRs can cause more tests (against MBRs) to be done. In general, can cause more tests (against MBRs) to be done. In general, this is not the casethis is not the case
Searching R-trees: point querySearching R-trees: point query
Test query point for inclusion in MBRs stored at each nodeTest query point for inclusion in MBRs stored at each nodestarting at root nodestarting at root node
Stop at leaf nodesStop at leaf nodesTest query point for inclusion in exact geometriesTest query point for inclusion in exact geometries
Exercise: Exercise: point querypoint query
a
b
c
d a b c d
R
S
R S
root
root
R-tree1
2 3
4
56
7
8
9
Pointers to geometries
4 5 6 7 8 91 2 3
P
5
Searching R-trees: point querySearching R-trees: point query
Example:Example:
a b
R S
root
R-tree1
2 3
4
6
7
8
9
43
a
b
root
R
S
Pointers to geometries
P
SummarySummary
• Indexing Vector Spatial DataIndexing Vector Spatial Data
• R-trees:R-trees:
• Based on MBRs (leaves)Based on MBRs (leaves)
• Root: whole datasetRoot: whole dataset
• Intermediate nodes: groups of MBRs (objects) – not Intermediate nodes: groups of MBRs (objects) – not a partition of the underlying space!a partition of the underlying space!
Important remarksImportant remarks
• Note that the MBRs (at all levels) can overlapNote that the MBRs (at all levels) can overlap
• A rectangle is stored as child of a bigger rectangle A rectangle is stored as child of a bigger rectangle only if only if completely contained in itcompletely contained in it
Example:Example:
Next lecture:Next lecture: Quadtrees for vector data (seen for raster) Quadtrees for vector data (seen for raster)