Polygon.contains和Polygon.within有什么区别?

Sou*_*nak 8 python polygon shapely

Docstring说:

Polygon.contains 如果几何包含另一个,则返回True,否则返回False

Polygon.within 如果几何在另一个内,则返回True,否则返回False

他们有什么不同?

che*_*ner 16

它们是反向关系:A包含B,并且B在其中A.

   >>> A.contains(B)
   True
   >>> B.within(A)
   True

   +----------------------------------+
   |                                  |
   |         +----------+             |
   |         |          |             |
   |         |          |             |
   |         |          |             |
   |         |          |             |
   |         |          |             |
   |         |    B     |             |
   |         |          |             |
   |         +----------+             |
   |                                  |
   |                                  |
   |   A                              |
   |                                  |
   +----------------------------------+
Run Code Online (Sandbox Code Playgroud)