GEOS Library Learning Three: spatial relationships, de-9im and predicates

Source: Internet
Author: User

To judge the relationship of two polygons, it is actually the geometry spatial relation judgment. Geometry is not only a polygon, it includes any shape of points, lines, polygons, and there are many relationships between 22, so the spatial relationship is very complex. According to the previous research, the DE-9IM model is summed up as a criterion of spatial relation judgment.

De-9im, the full name is dimensionally Extended nine-intersection model (DE-9IM), is a topological model used to describe a standard for the spatial relationship of two geometries. In the area of specialization, each geometry is typically divided into three parts: external (exterior), boundary (boundary), and internal (interior). In a similar way, what are the three parts of a rectangle referring to each other? The relationship judgment of two graphs is actually a separate judgment of three parts, so there will be a 3*3 cross-matrix, which is the DE-9IM model, such as:

Where A, b represents two faces respectively, and the i,b,e represents three parts respectively. The Dim () function represents the dimension of the intersecting part. If the intersection is a polygon, it is a two-dimensional, dim () = 2, or one-dimensional, dim () = 1 if the intersection is a line, or 0-dimensional, dim () = 0 if the intersection is some point, or dim () =-1 If it does not intersect, and the matrix is read from the top down, left to right, There will be a string, such as "212101212", to convert the relationship to a string, the final judgment on the string is OK. The above figure is just one of many relationships, and the picture is intersecting, so there is no case of-1.

In other words, we will (0,1,2) think of the intersection, written as t,-1 that does not intersect, write F. Then "212101212" becomes "ttttttttt". In fact, these 9 values, we just need to know a few of the values can be judged, do not need to know all. For example, if we know that the first bit is T, we can judge the intersection of the two, and what the next 8 bits don't care about. Don't care what the value is, we use * instead, so we just see "t********", we know two graphs intersect.

To express relationships in terms of jargon, we call them predicates, such as intersection, contact, overlap, inclusion, etc. The relationship is more and the definition is very fine. We only consider the relationship of two polygons (two polygons), so we only need to master a few relationships. If you need to judge the point, line relations, suggest go to Https://en.wikipedia.org/wiki/DE-9IM carefully look, introduce very detailed.

There are two main types of relationships between polygons: intersection and detachment (disjoint), which are divided into contacts, overlaps, overrides, and equality.

Predicate return value Describe
Equal (equals) T*F**FFF* The points on the boundary and the inner points all overlap. One of the intersecting
Detachment (disjoint) FF*FF**** Disjoint, opposite to intersect
Contact (touches) FT*******\F**T*****\F***T**** Only the boundaries have something in common, not inside. One of the intersecting
Overlay (covers) T*****FF*\*T****FF*\***T**FF*\****T*FF* Each point on B is on a (boundary and interior), and all points are not outside a. One of the intersecting
Overlap (overlaps) T*T***T**\1*T***T** A and b intersect, and have a part in common, but not all internal points. One of the intersecting

Respectively: coverage, contact, and overlap

In GeoS, these five relationships, each with corresponding functions, return a BOOL value

A->equals (b)   // to determine whether AB is equal, return A->disjoint (b)  // to determine whether AB is detached // To determine if AB is in contact with a->covers (b)   // to determine if AB is covered, note and contains differ /  Determine if they have overlapping parts

In addition, if AB is detached, it can also be used

A->distance (b) calculates the shortest distance between the two.

If AB overlaps, you can also use

A->intersection (b) Returns the geometry of the intersecting part.

If you don't know what the relationship is between the two, you can use

A->relate (b) returns a string of strings and then matches the string to see which relationship it belongs to.

Specific code practice follow-up

GEOS Library Learning Three: spatial relationships, de-9im and predicates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.