spatial index(2)
TRANSCRIPT
![Page 1: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/1.jpg)
EMAIL : [email protected]
TEL :(+98) 9378812726
IN THE NAME OF ALLAH
PRESENTOR: Mohsen Rashidian www.GeoBook.ir
CONTACT INFO:
www.geobook.ir
SPATIAL INDEXING
![Page 2: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/2.jpg)
PREDICTED TIME : 30 MIN SLIDE NOM:41
SUBJECT:
SPATIAL INDEXING EMAIL
www.geobook.ir
![Page 3: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/3.jpg)
CONTENTS…
What is an index? Main index types… Point access methods(PAMS)… Spatial access methods(SAMS)… R-TREE issues Summary References
www.geobook.ir
![Page 4: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/4.jpg)
What is an index?
Concept of an index: “auxiliary file to search a data file“
index records have •key value •address of relevant data sector (arrows) In general indices improve access time but may cause deletion And insertion data items can increase processing time!
www.geobook.ir
![Page 5: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/5.jpg)
An index in general…
Assume we have some files… In computer science 4 ways are exist:
1-pile records 2-fixed size records 3-sequential records 4-indexed sequential
No meaningful sequence worst access time best insertion time
better access time(fixed size) Still best insertion time Ordered by a key sequence value good access time Low speed insertion time(to keep sequence order)
Include the primary data area and an indexed area good access time Good insertion time(may need to refer indexed area)
www.geobook.ir
![Page 6: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/6.jpg)
Main index types
Point access methods(PAMs) i. Grid File ii. kd-tree based
iii. Z-ordering iv. B-tree
Spatial access methods(SAMS) i. R-TREE(R*-tree, Hilbert R-tree)
www.geobook.ir
![Page 7: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/7.jpg)
Point access methods(PAMS)
PAM: index only point data Multidimensional Hashing(grid files)
Hierarchical (tree-based) structures (kd-tree)
Space filling curve(z-ordering or quad-tree)
The problem
Given a point set and a rectangular query, find the points enclosed in the query
www.geobook.ir
![Page 8: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/8.jpg)
PAMS>Grid File
Idea: Use a grid to partition the space each cell is associated with one page
Exponential growth of the directory implementation
Grid array: 2 dimensional array with pointers to buckets G(0,…, nx-1, 0, …, ny-1) Linear scales: Two 1 dimensional arrays that used to access the grid array X(0, …, nx-1), Y(0, …, ny-1)
www.geobook.ir
![Page 9: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/9.jpg)
PAMS>Grid File>Example
Linear scale X
Linear scale
Y
Grid Directory
Buckets/Disk
Blocks
www.geobook.ir
![Page 10: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/10.jpg)
PAMS>KD-TREE
kd-tree is a main memory binary tree for indexing k-dimensional points
Storing in external memory is tricky At each level we use a different dimension
kd-tree is not necessarily balanced
A
B C
D E
x=5
y=6
x=6
Y=3
www.geobook.ir
![Page 11: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/11.jpg)
X=5
y=5 y=6
x=3
y=2
x=8 x=7
X=5 X=8
X=7
Y=6
Y=2
Y=5
X=3
PAMS>KD-TREE>Example
www.geobook.ir
![Page 12: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/12.jpg)
Map points from 2-dimensions to 1-dimension
Basic assumption: Finite precision in the representation of each co-ordinate, K bits
(2K values)
The address space is a square (image) and represented as a 2K x 2K array
Each element is called a pixel
PAMS> Z-ordering
www.geobook.ir
![Page 13: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/13.jpg)
PAMS> Z-ordering
Impose a linear ordering on the pixels of the image 1 dimensional problem
00 01 10 11 00
01
10
11
A ZA = shuffle(xA, yA) = shuffle(“01”, “11”)
= 0111 = (7)10
www.geobook.ir
![Page 14: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/14.jpg)
PAMS> Z-ordering for Regions
Break the space into 4 equal quadrants: level-1 blocks For a level-i block: all its pixels have the same prefix up to
2i bits; the z-value of the block
www.geobook.ir
![Page 15: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/15.jpg)
Object is recursively divided into blocks until: Blocks are homogeneous Pixel level
Quadtree: ‘0’ stands for S and W ‘1’ stands for N and E
00 01 10 11 00
01
10
11
SW SE
NW
NE
11 00 10
01
11 1001 1011
PAMS> Quad tree
www.geobook.ir
![Page 16: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/16.jpg)
Quad tree(2D)
00 01 10 11
00 01 10 11
00 01
10 11
00 01
10 10
www.geobook.ir
![Page 17: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/17.jpg)
Quad-tree(3D) or Oc-tree
010 011 100 101 000 001 110 111
010 011 100 101 000 001 110 111
000 001 010 011 100 101 110 111
www.geobook.ir
![Page 18: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/18.jpg)
PAMS>B-TREE
Good access time Reasonable sequential read on the sequence key Insertion and deletion do not damage the balance
of the tree
www.geobook.ir
![Page 19: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/19.jpg)
Spatial access methods(SAMS)
Indexes for spatial data that have extend (not only point data)
Use only Minimum Bounding Rectangles –MBRs (filtering)
R-tree (Guttman, 1984) is the prominent SAM Implemented in Oracle, Postgres, Informix
www.geobook.ir
![Page 20: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/20.jpg)
2-dimensional version of the B-tree!
SAMS>R-TREE
Can store: i. a set of polygons (regions of a subdivision) ii. a set of polygonal lines (or boundaries) iii. a set of points iv. a mix of the above
Stored objects may overlap
www.geobook.ir
![Page 21: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/21.jpg)
SAMS>R-TREE
Originally by Guttman, 1984 Dozens of variations and optimizations since Suitable for windowing, point location and intersection
queries
Every internal node contains entries (rectangle, pointer to child node) All leaves contain entries (rectangle, pointer to object) in database or file Rectangles are minimal bounding rectangles (MBR)
Definition R-tree:
www.geobook.ir
![Page 22: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/22.jpg)
SAMS>R-TREE>Grouping of objects
Objects close together in same leaves ⇒ small rectangles ⇒ queries descend in only few subtrees
Group the child nodes under a parent node such that small rectangles arise
www.geobook.ir
![Page 23: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/23.jpg)
Heuristics for fast queries
Small area of rectangles Small perimeter of rectangles Little overlap among rectangles
Good access time
Reasonable amount of insertion and deletion does not cause tree reconstraction
Height number of deletion and insertion requires restruction of tree
www.geobook.ir
![Page 24: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/24.jpg)
SAMS>R-TREE>Example
www.geobook.ir
![Page 25: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/25.jpg)
SAMS>R-TREE>Example
www.geobook.ir
![Page 26: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/26.jpg)
SAMS>R-TREE>Example
www.geobook.ir
![Page 27: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/27.jpg)
SAMS>R-TREE>Example
www.geobook.ir
![Page 28: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/28.jpg)
SAMS>R-TREE>Example
www.geobook.ir
![Page 29: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/29.jpg)
SAMS>R-TREE>Example
point containment query
www.geobook.ir
![Page 30: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/30.jpg)
SAMS>R-TREE>Example
point containment query
www.geobook.ir
![Page 31: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/31.jpg)
SAMS>R-TREE>Searching
Q is query object (point, window, object) For each rectangle R in the current node,
if Q and R intersect,
search recursively in the subtree under the pointer at R (at an internal node)
get the object corresponding to R and test for intersection with R (at a leaf)
www.geobook.ir
![Page 32: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/32.jpg)
SAMS>R-TREE>Inserting
Determine minimal bounding rectangle (MBR) of new object When not yet at a leaf (choose subtree):
i. determine rectangle whose area increment after insertion of R is smallest
ii. increase this rectangle if necessary and insert R
At a leaf: i. if there is space, insert, otherwise Split Node
New MBRs
Split Node
www.geobook.ir
![Page 33: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/33.jpg)
SAMS>R-TREE>Deletion
Find the leaf (node) and delete object; determine new (possibly smaller) MBR
If the node is too empty (< m entries): i. delete the node recursively at its parent
ii. insert all entries of the deleted node into the R-tree
Note: Insertions of entries/sub-trees always occurs at the level where it came from
www.geobook.ir
![Page 34: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/34.jpg)
SAMS>R-TREE>Deletion>Example
Should deleted www.geobook.ir
![Page 35: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/35.jpg)
SAMS>R-TREE>Deletion>Example
www.geobook.ir
![Page 36: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/36.jpg)
SAMS>R-TREE>Deletion>Example
www.geobook.ir
![Page 37: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/37.jpg)
SAMS>R-TREE>Deletion>Example
www.geobook.ir
![Page 38: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/38.jpg)
SAMS>R-TREE>Deletion>Example
www.geobook.ir
![Page 39: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/39.jpg)
R*-TREES!
Is there any other property that can be optimized? R*-tree Yes!
Optimization Criteria: i. Area covered by an index MBR
ii. Overlap between directory MBRs
iii. Margin of a directory rectangle
iv. Storage utilization
Sometimes it is impossible to optimize all the above criteria at the same time!
www.geobook.ir
![Page 40: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/40.jpg)
REFRENCES…
H. V. Jagadish: Linear Clustering of Objects with Multiple Atributes. ACM SIGMOD Conference 1990: 332-342
Walid G. Aref, Hanan Samet: A Window Retrieval Algorithm for Spatial Databases Using Quadtrees. ACM-GIS 1995: 69-77
A. Guttman (1984). R-trees: A dynamic index structure for spatial searching. Proc. A CM SIGMOD Int. Conf. on Management of Data, pages 47-57.
Oracle Spatial 10g White Paper (2006). Oracle Spatial Quadtree Indexing, 10g Release 1 (10.1).
بخش “ پايگاه داده مکانی“جزوه کالسی درس1388.حکيم پورفDATA INDEXING دوره .دانشگاه صنعتی کرمان GISکارشناسی ارشد
www.geobook.ir
![Page 41: Spatial index(2)](https://reader036.vdocuments.net/reader036/viewer/2022062313/55a6b9371a28abe6088b45c9/html5/thumbnails/41.jpg)
www.geobook.ir