Presentation is loading. Please wait.

Presentation is loading. Please wait.

Trees for spatial data representation and searching

Similar presentations


Presentation on theme: "Trees for spatial data representation and searching"— Presentation transcript:

1 Trees for spatial data representation and searching
CPSC 335 Trees for spatial data representation and searching

2 Overview Interval trees K-d trees Grids and Grid files using B-trees
Spatial data structures Interval trees K-d trees Grids and Grid files using B-trees R-trees

3 Trees BST – search trees, O(n) AVL, IPR – balanced O(log n)
B-trees – for indexing and searching in data bases: Grow from the leaf level More compact – faster search B+, B* - used for indexing, store data in leaves, nodes are more full

4 Spatial data applications
GIS (Geographic Information Systems) CAD (Computer Aided Design) VLSI (Very Large Scale Integration, IBM) Robotics Image Processing

5 Spatial objects point segment line circle sphere polygon polyhedron
Convex, concave Simple, Non-simple With holes, without holes polyhedron

6 Operations on spatial objects
Stored Displayed Manipulated Queried

7 Examples of applications

8 Data collection from GPS (Global Positioning Systems) – BMP, GIF, GPEG, etc… from existing maps, geometric (vector) representation from experiments (physical, biological, mechanical) - attributes generated for experiments – data files text, images)

9 Operations on spatial data
Spatial queries Point location Stabbing query (report all intervals/polygons contain the point)

10 Spatial queries (2D) Point query – find an object containing a point (find a Voronoi region containing a point) Window query – find an object overlapping a rectangle Spatial join – join parts of objects satisfying some relationship (intersection, adjacency, containment)

11 Overview Interval trees K-d trees Grids and Grid files using B-trees
Spatial data structures Interval trees K-d trees Grids and Grid files using B-trees R-trees

12 Interval trees Geometric, 1-dimensional tree
Interval is defined by (x1,x2) Split at the middle (5), again at the middle (3,7), again at the middle (2,8) All intervals intersecting a middle point are stored at the corresponding root (sorted). (4,6) (4,8) 1 2 3 4 5 6 7 8 9 (6,9) (2,4) (7.5,8.5)

13 Interval trees Finding intervals – by finding x1, x2 against the nodes
Find interval containing specific value – from the root Sort intervals within each node of the tree according to their coordinates Cost of the “stabbing query”– finding all intervals containing the specified value is O(log n + k), where k is the number of reported intervals.

14 Construction We start by taking the entire range of all the intervals and dividing it in half at x_center (in practice, x_center could be picked as MEDIAN to keep the tree relatively balanced). This gives three sets of intervals, those completely to the left of x_center which we'll call S_left, those completely to the right of x_center which we'll call S_right, and those overlapping x_center which we'll call S_center. The intervals in S_left and S_right are recursively divided in the same manner until there are no intervals left. The intervals in S_center that overlap the center point are stored in a separate data structure linked to the node in the interval tree.

15 Resulting tree data structure
The result is a binary tree with each node storing: A center point A pointer to another node containing all intervals completely to the left of the center point A pointer to another node containing all intervals completely to the right of the center point All intervals overlapping the center point sorted by their beginning point All intervals overlapping the center point sorted by their ending point

16 Interval Tree using MEDIAN
Let I:={[x1:x1’], [x2:x2’], …, [xn:xn’]} be a set of closed intervals. Let xmid be the Median of the 2n interval endpoints At most half of the interval endpoints lies to the left of xmid and at most half to the right. Then the resulting Interval Tree is more Balanced than standard Interval Tree

17 Example of interval tree using Median

18 Properties An interval tree for a set I of n intervals use O(n) storage and can be built in O(nlogn) time. Using the interval tree we can report all intervals that contain a query point in O(logn+k) time, where k is the number of reported intervals.

19 Overview Interval trees K-d trees Grids and Grid files using B-trees
Spatial data structures Interval trees K-d trees Grids and Grid files using B-trees R-trees

20 K-d tree Used for point location and multiple database quesries, k –number of the attributes to perform the search Geometric interpretation – to perform search in 2D space – 2-d tree Search components (x,y) interchange!

21 K-d tree K-d tree a space-partitioning data structure for organizing points in a k-dimensional space. The kd-tree is a binary tree in which every node is a k- dimensional point. Every non-leaf node generates a splitting hyperplane that divides the space into two subspaces. Points left to the hyperplane represent the left sub-tree of that node and the points right to the hyperplane by the right sub- tree. The hyperplane direction is chosen in the following way: every node split to sub-trees is associated with one of the k- dimensions, such that the hyperplane is perpendicular to that dimension vector. So, for example, if for a particular split the "x" axis is chosen, all points in the subtree with a smaller "x" value than the node will appear in the left subtree and all points with larger "x" value will be in the right sub tree. Hyperplane direction ROTATES over all k dimensions!

22 K-d tree example d d e c f b f c a e b a

23 K-d tree construction The canonical method of kd-tree construction is:
As one moves down the tree, one cycles (rotates) through the axes used to select the splitting planes. (For example, the root would have an x-aligned plane, the root's children would both have y- aligned planes, the root's grandchildren would all have z-aligned planes, the next level would have an x-aligned plane, and so on.) Points are inserted by selecting the median of the points being put into the subtree, with respect to their coordinates in the axis being used to create the splitting plane. This method leads to a balanced kd-tree, in which each leaf node is about the same distance from the root. Note also that it is not required to select the median point. In that case, the result is simply that there is no guarantee that the tree will be balanced. A simple heuristic to avoid coding a complex linear-time median-finding algorithm nor using an O(n log n) sort is to use sort to find the median of a fixed number of randomly selected points to serve as the cut line. Practically this technique often results in nicely balanced trees.

24 Overview Interval trees K-d trees Grids and Grid files using B-trees
Spatial data structures Interval trees K-d trees Grids and Grid files using B-trees R-trees

25 Progressive Meshes Developed by Hugues Hoppe, Microsoft Research Inc. Published first in SIGGRAPH 1996.

26 Terrain visualization applications

27 Geometric subdivision
Problems with Geometric Subdivisions

28 The basic operating principle of ROAM
ROAM principle The basic operating principle of ROAM

29 Quad-tree and Bin-tree for ROAM (real-time adaptive mesh)

30 The grid Fixed grid: Stored as a 2D array, each entry contains a link to a list of points (object) stored in a grid. a,b

31 Page overflow Too many points in one grid cell: Split the cell!

32 Grid file Example of a grid file

33 Grid file vs. grid In a grid file, the index is dynamically increased in size when overflow happens. The space is split by a vertical or a horizontal line, and then further subdivided when overflow happens! Index is dynamically growing Boundaries of cells of different sizes are stores, thus point and stabbing queries are easy

34 Rectangle indexing with grids
Rectangles may share different grid cells Duplicates are stored Grid cells are of fixed size

35 The quadtree Instead of using an array as an index, use tree!
Quadtree decomposition – cells are indexed by using quaternary B-tree. All cells are squares, not polygons. Search in a tree is faster!

36 Linear quadtree B+ index – actual references to rectangles are stored in the leaves, saving more space+ access time Label nodes according to Z or “pi” order

37 Linear quadtree Level of detail increases as the number of quadtree decompositions increases! Decompositions have indexes of a form: 00,01,02,03,10,11,12,13, 2,300 301 ,302 ,303 ,31 ,32 ,33 Stores as Bplus tree

38 Finer Grid R-tree Each object s decomposed and stored as a set of rectangles Object decomposition: Larger areas of a grid are treated as one element Raster decomposition: Each smaller element s stored separately

39 R-trees R-tree R * tree- Optimizes
Objects are grouped together according to topological properties not a grid. More flexibility. R * tree- Optimizes Node overlapping Areas covered by the node R+ tree – B+ tree, bounding rectangles do not intersect

40 Conclusions Interval trees K-d trees
Spatial data structures such as Interval trees K-d trees Grids and Grid files using B-trees R-trees are used in variety of applications. They are often balanced, good for searching, DB queryng, spatial queryng and utilize Index and B tree concepts.


Download ppt "Trees for spatial data representation and searching"

Similar presentations


Ads by Google