I try to understand the Spatial predicates of the DE-9IM Intersection matrix. I don't get the difference between predicates Covers (respective CoveredBy) and Contains (resp. Within).

I try to draw geometries with JTS Topology Suite, they are always Covers = True and Contains = True (or both are False) but I don't manage to make them different, i.e. to see the difference between Covers and Contains. Does anybody have an example (preferably an WKT or a picture) which illustrate the difference?


Look at Martin Davis (creator of the JTS Topology Suite), Lin.ear th.inking: Quirks of the "Contains" Spatial Predicate

  1. Geometry A contains Geometry B if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A
  2. Geometry A covers Geometry B if no points of B lie in the exterior of A

All that is necessary to determine this condition is to perform a simple bounding box comparison. This is not possible with contains, because even if the bounding box of Geometry is covered by the Rectangle, a further expensive operation is required to test if the Geometry lies wholly in the boundary of the Rectangle (in which case the predicate fails). Covers "simplifies" the definition of contains by making it more general (inclusive)

If you look at DE-9IM, you can see that contains (T*****FF*) is a particular case of covers (T*****FF*, *T****FF*, ***T**FF*)

For example, the definition of contains implies that a Polygon do not contain its boundary but a Polygon covers its boundary.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.