Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Geometric Objects(几何对象)
  6. Collections of Lines(复合线)

Collections of Lines(复合线)

class MultiLineString(lines)

The MultiLineString constructor takes a sequence of line-like sequences or objects.

MultiLineString构造函数接收线性元祖序列或对象。

(Source codepnghires.pngpdf)

Figure 6. On the left, a simple , disconnected MultiLineString , and on the right, a non-simple MultiLineString. The points defining the objects are shown in gray, the boundaries of the objects in black.图6. 左边是一个简单的、不相连的复合线,右边是一个有连接的复合线。定义对象的点以灰色显示,对象的边界以黑色显示。

A MultiLineString has zero area and non-zero length.

MultiLineString的面积为零,长度不为零。

>>> from shapely.geometry import MultiLineString
>>> coords = [((0, 0), (1, 1)), ((-1, 0), (1, 0))]
>>> lines = MultiLineString(coords)
>>> lines.area
0.0
>>> lines.length
3.4142135623730949

Its x-y bounding box is a (minx, miny, maxx, maxy) tuple.

其边界是一个元组(minx, miny, maxx, maxy)。

>>> lines.bounds
(-1.0, 0.0, 1.0, 1.0)

Its members are instances of LineString and are accessed via the geoms property or via the iterator protocol using in or list().

其成员可以通过geoms属性或通过in、list()的迭代器协议来访问。

>>> len(lines.geoms)
2
>>> pprint.pprint(list(lines.geoms))
[<shapely.geometry.linestring.LineString object at 0x...>,
 <shapely.geometry.linestring.LineString object at 0x...>]
>>> pprint.pprint(list(lines))
[<shapely.geometry.linestring.LineString object at 0x...>,
 <shapely.geometry.linestring.LineString object at 0x...>]

The constructor also accepts another instance of MultiLineString or an unordered sequence of LineString instances, thereby making copies.

构造函数也接受另一个MultiLineString的实例或LineString实例的无序序列,从而得到一个副本。

>>> MultiLineString(lines)
<shapely.geometry.multilinestring.MultiLineString object at 0x...>
>>> MultiLineString(lines.geoms)
<shapely.geometry.multilinestring.MultiLineString object at 0x...>
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here