Python, Shapely: what is the difference between Polygon.contains and Polygon.within?

Dokstrin says:

Polygon.contains Returns True if the geometry contains another, otherwise False

Polygon.within Returns True if the geometry is inside another, otherwise False

How do they differ?

+5
source share
1 answer

They are inverse relationships: A contains B , and B lies within A

  >>> A.contains(B) True >>> B.within(A) True +----------------------------------+ | | | +----------+ | | | | | | | | | | | | | | | | | | | | | | | B | | | | | | | +----------+ | | | | | | A | | | +----------------------------------+ 
+11
source

All Articles