Jump to content
[[Template core/front/custom/_customHeader is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]

Quadtrees


Kid Cid
 Share

Recommended Posts

It's been a while since I've done any significant Geographic research so I wanted to revisit a topic I spent some time in previously and that is quadtrees. I'm omitting references here only because I'm lazy, they can be provided upon request.

 

Simply put, a quadtree is a tree data structure that is useful for the storage of certain types of spatial data. Unlike a binary tree, an R-tree or a B-tree which are all binary structures, each node of the quadtree can have up to four children. Quadtrees are most often used to partition a two dimensional space by recursively subdividing it into four quadrants or regions. The regions may be square or rectangular, or may have arbitrary shapes. This data structure was named a quadtree by Raphael Finkel and J.L. Bentley in 1974. All forms of Quadtrees share some common features:

 

  • They decompose space into adaptable cells
  • Each cell (or bucket) has a maximum capacity. When maximum capacity is reached, the bucket splits
  • The tree directory follows the spatial decomposition of the Quadtree

 

Quadtrees are typically classified by the type of data they contain most notably, points, lines, and areas (polygons). Of great interest to geographers and one of the reasons for the quadtrees usefullness is that the topology of spatial elements can be contained within the data structure itself rather than having to be assembled from a separate mathematical algorithm that needs to be run against the dataset. This is not an abolute condition of quadtrees however.

 

Some common types of quadtrees are:

 

The region quadtree

The region quadtree represents a partition of space in two dimensions by decomposing the region into four equal quadrants, subquadrants, and so on with each leaf node containing data corresponding to a specific subregion. Each node in the tree either has exactly four children, or has no children (a leaf node). The region quadtree is not strictly a 'tree' - as the positions of subdivisions are independent of the data. They are more precisely called 'tries'.

 

A region quadtree with a depth of n may be used to represent an image consisting of 2n * 2n pixels, where each pixel value is 0 or 1. The root node represents the entire image region. If the pixels in any region are not entirely 0s or 1s, it is subdivided. In this application, each leaf node represents a block of pixels that are all 0s or all 1s.

 

A region quadtree may also be used as a variable resolution representation of a data field. For example, the temperatures in an area may be stored as a quadtree, with each leaf node storing the average temperature over the subregion it represents.

 

If a region quadtree is used to represent a set of point data (such as the latitude and longitude of a set of cities), regions are subdivided until each leaf contains at most a single point.

 

 

Point quadtree

The point quadtree is an adaptation of a binary tree used to represent two dimensional point data. It shares the features of all quadtrees but is a true tree as the centre of a subdivision is always on a point. The tree shape depends on the order data is processed. It is often very efficient in comparing two dimensional ordered data points, usually operating in O(log n) time.

 

 

Node structure for a point quadtree

A node of a point quadtree is similar to a node of a binary tree, with the major difference being that it has four pointers (one for each quadrant) instead of two ("left" and "right") as in an ordinary binary tree. Also a key is usually decomposed into two parts, referring to x and y coordinates. Therefore a node contains following information:

 

4 Pointers: quad[‘NW’], quad[‘NE’], quad[‘SW’], and quad[‘SE’]

point; which in turn contains:

key; usually expressed as x, y coordinates

value; for example a name

 

Edge quadtree

Edge quadtrees are specifically used to store lines rather than points. Curves are approximated by subdividing cells to a very fine resolution. This can result in extremely unbalanced trees which may defeat the object of indexing.

 

A final important point to note about quadtrees is that If geometric subdividing fails to reduce the item count for each quadrant, (e.g., for overlapping data,) quadtree subpartitioning fails, and the capacity must be breached for the algorithm to continue. For example, if the maximum capacity for a quadrant is 8, and there are 9 points at (0, 0), subpartitioning would produce three empty quadrants, and one containing the original 9 points, and so on. Because the tree must allow more than 8 points in such a quadrant, quadtree can approach O(N) complexity for data sets with arbitrary geometry (e.g., maps or graphs).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information