The LineString constructor takes an ordered sequence of 2 or more (x, y[, z])
point tuples.
LineString构造函数接收2个或多个(x, y[, z])点元祖。
The constructed LineString object represents one or more connected linear splines between the points. Repeated points in the ordered sequence are allowed, but may incur performance penalties and should be avoided. A LineString may cross itself (i.e. be complex and not simple).
构建的LineString对象代表一个或多个点之间的连接线性样条。允许在有序序列中重复的点,但可能会产生性能惩罚,因此应当避免。一个LineString可以与自己交叉(即复杂而不简单)。
在Shapely中,线状几何要素分为简单线(下图a)和复杂线(下图b,复杂线是自相交的)。
(Source code, png, hires.png, pdf)
A LineString has zero area and non-zero length.
一个LineString的面积为零,长度不为零。
>>> from shapely import LineString
>>> line = LineString([(0, 0), (1, 1)])
>>> line.area
0.0
>>> line.length
1.4142135623730951
Its x-y bounding box is a (minx, miny, maxx, maxy)
tuple.
它的边界是一个元组(minx, miny, maxx, maxy)。
>>> line.bounds
(0.0, 0.0, 1.0, 1.0)
The defining coordinate values are accessed via the coords property.
定义的坐标值可以通过coords属性访问。
>>> len(line.coords)
2
>>> list(line.coords)
[(0.0, 0.0), (1.0, 1.0)]
Coordinates may also be sliced. New in version 1.2.14.
coords属性支持切片操作。
>>> line.coords[:]
[(0.0, 0.0), (1.0, 1.0)]
>>> line.coords[1:]
[(1.0, 1.0)]
The constructor also accepts another LineString instance, thereby making a copy.
构造函数也接收另一个LineString实例,从而得到一个副本。
>>> LineString(line)
<LINESTRING (0 0, 1 1)>
A LineString may also be constructed using a sequence of mixed Point instances or coordinate tuples. The individual coordinates are copied into the new object.
LineString也可以使用混合点实例或坐标元祖来构造。各个坐标值会被复制到新的对象中。
>>> LineString([Point(0.0, 1.0), (2.0, 3.0), Point(4.0, 5.0)])
<LINESTRING (0 1, 2 3, 4 5)>