Shapely 2.0.0 中文文档

  1. 主页
  2. 文档
  3. Shapely 2.0.0 中文文档
  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 import MultiLineString
>>> coords = [((0, 0), (1, 1)), ((-1, 0), (1, 0))]
>>> lines = MultiLineString(coords)
>>> lines.area
0.0
>>> lines.length
3.414213562373095

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.

其成员可以通过geoms属性来访问。

>>> len(lines.geoms)
2
>>> print(list(lines.geoms))
[<LINESTRING (0 0, 1 1)>, <LINESTRING (-1 0, 1 0)>]

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

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

>>> MultiLineString(lines)
<MULTILINESTRING ((0 0, 1 1), (-1 0, 1 0))>
>>> MultiLineString(lines.geoms)
<MULTILINESTRING ((0 0, 1 1), (-1 0, 1 0))>
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here