Shapely 2.0.0 中文文档

  1. 主页
  2. 文档
  3. Shapely 2.0.0 中文文档
  4. User Manual
  5. Geometric Objects(几何对象)
  6. Collections(集合)

Collections(集合)

Heterogeneous collections of geometric objects may result from some Shapely operations. For example, two LineStrings may intersect along a line and at a point. To represent these kind of results, Shapely provides frozenset-like, immutable collections of geometric objects. The collections may be homogeneous (MultiPoint etc.) or heterogeneous.

一些Shapely操作可能会出现多项几何对象的集合(collections)。例如,两个LineString可能沿着一条线和在一个点相交。为了表示这些结果,Shapely提供了类似于frozenset的、不可改变的几何对象的集合。这些集合可以是同质的(复合点等)或异质的(点与线的集合)。

>>> a = LineString([(0, 0), (1, 1), (1,2), (2,2)])
>>> b = LineString([(0, 0), (1, 1), (2,1), (2,2)])
>>> x = a.intersection(b)
>>> x
<GEOMETRYCOLLECTION (LINESTRING (0 0, 1 1), POINT (2 2))>
>>> list(x.geoms)
[<LINESTRING (0 0, 1 1)>, <POINT (2 2)>]

(Source codepnghires.pngpdf)

Figure 5. a) a green and a yellow line that intersect along a line and at a single point; b) the intersection (in blue) is a collection containing one LineString and one Point.图5. a) 一条绿色和一条黄色的线,在一条线和一个点上相交;b) 交点(蓝色)是一个包含一个LineString和一个Point的集合。

Members of a GeometryCollection are accessed via the geoms property.

几何集合(GeometryCollection)的成员可以通过geoms属性来访问。

>>> list(x.geoms)
[<LINESTRING (0 0, 1 1)>, <POINT (2 2)>]
Note:When possible, it is better to use one of the homogeneous collection types described below.在可能的情况下,最好使用后面描述的同质化集合类型之一。
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here