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 code, png, hires.png, pdf)
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.在可能的情况下,最好使用后面描述的同质化集合类型之一。