Shapely 2.0.0 中文文档

  1. 主页
  2. 文档
  3. Shapely 2.0.0 中文文档
  4. User Manual
  5. Predicates and Relationships(谓词和关系)
  6. DE-9IM Relationships(DE九交模型关系)

DE-9IM Relationships(DE九交模型关系)

The relate() method tests all the DE-9IM [4] relationships between objects, of which the named relationship predicates above are a subset.

relate()方法用于测试对象之间的所有DE九交模型关系,上面的命名关系谓词是其中的一个子集。

  • object.relate(other)

Returns a string representation of the DE-9IM matrix of relationships between an object’s interior, boundary, exterior and those of another geometric object.

返回一个对象与另一个几何对象的内部、边界、外部之间的DE九交模型矩阵的字符串表示。

The named relationship predicates (contains(), etc.) are typically implemented as wrappers around relate().

命名的关系谓词(contains()等)通常作为relate()的进一步封装来实现。

Two different points have mainly F (false) values in their matrix; the intersection of their external sets (the 9th element) is a 2 dimensional object (the rest of the plane). The intersection of the interior of one with the exterior of the other is a 0 dimensional object (3rd and 7th elements of the matrix).

两个不同的点在它们的矩阵中主要有假F值(false);它们的外部交集(第9个元素)是一个2维的对象(平面的其余部分)。一个对象的内部与另一个对象的外部的交集是一个0维物体(矩阵的第3和第7元素)。

>>> Point(0, 0).relate(Point(1, 1))
'FF0FFF0F2'

The matrix for a line and a point on the line has more “true” (not F) elements.

一条直线和直线上的一个点的矩阵有更多的非 F值。

>>> Point(0, 0).relate(LineString([(0, 0), (1, 1)]))
'F0FFFF102'
  • object.relate_pattern(otherpattern)

Returns True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, otherwise False.

如果几何对象之间的DE九交模型关系的字符串代码满足模式,则返回True,否则返回False。

The relate_pattern() compares the DE-9IM code string for two geometries against a specified pattern. If the string matches the pattern then True is returned, otherwise False. The pattern specified can be an exact match (01 or 2), a boolean match (T or F), or a wildcard (*). For example, the pattern for the within predicate is T*****FF*.

relate_pattern()将两个几何对象的DE九交模型关系代码字符串与指定的模式进行比较。如果字符串与模式匹配,则返回True,否则返回False。指定的模式可以是精确匹配(0、1或2),布尔匹配(T或F),或通配符()。例如,内部谓词的模式是T*****FF*

>>> point = Point(0.5, 0.5)
>>> square = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
>>> square.relate_pattern(point, 'T*****FF*')
True
>>> point.within(square)
True

Note that the order or the geometries is significant, as demonstrated below. In this example the square contains the point, but the point does not contain the square.

请注意,几何对象的顺序是很重要的。在下面这个例子中,正方形包含点,但点不包含正方形。

>>> point.relate(square)
'0FFFFF212'
>>> square.relate(point)
'0F2FF1FF2'

Further discussion of the DE-9IM matrix is beyond the scope of this manual. See [4] and https://pypi.org/project/de9im/.

对DE-9IM矩阵的进一步讨论已经超出了本手册的范围。见[4]和https://pypi.org/project/de9im/.

标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here