Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Other Operations(其他操作)
  6. Substring(子集)

Substring(子集)

The substring() function in shapely.ops returns a line segment between specified distances along a LineString.

shapely.ops中的substring()函数返回沿LineString指定距离之间的线段。

  • shapely.ops.substring(geomstart_distend_dist[, normalized=False])

Return the LineString between start_dist and end_dist or a Point if they are at the same location

返回start_dist和end_dist之间的LineString,如果它们在同一位置,则返回一个Point。

Negative distance values are taken as measured in the reverse direction from the end of the geometry. Out-of-range index values are handled by clamping them to the valid range of values.

负的距离值被视为从几何体的末端反向测量。超出范围的索引值是通过将其夹在有效的数值范围内来处理。

If the start distance equals the end distance, a point is being returned.

如果开始距离等于结束距离,则返回一个点。

If the start distance is actually past the end distance, then the reversed substring is returned such that the start distance is at the first coordinate.

如果开始距离实际上超过了结束距离,那么将返回反转的子串,这样开始距离就在第一个坐标上。

If the normalized arg is True, the distance will be interpreted as a fraction of the geometry’s length

如果归一化的参数是True,那么距离将被解释为几何体长度的一小部分

New in version 1.7.0

Here are some examples that return LineString geometries.Here are some examples that return LineString geometries.

下面是一些返回LineString几何对象的例子。

>>> from shapely.geometry import LineString
>>> from shapely.ops import substring
>>> ls = LineString((i, 0) for i in range(6))
>>> ls.wkt
'LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)'
>>> substring(ls, start_dist=1, end_dist=3).wkt
'LINESTRING (1 0, 2 0, 3 0)'
>>> substring(ls, start_dist=3, end_dist=1).wkt
'LINESTRING (3 0, 2 0, 1 0)'
>>> substring(ls, start_dist=1, end_dist=-3).wkt
'LINESTRING (1 0, 2 0)'
>>> substring(ls, start_dist=0.2, end_dist=-0.6, normalized=True).wkt
'LINESTRING (1 0, 2 0)'

And here is an example that returns a Point.

这是一个返回点的例子。

>>> substring(ls, start_dist=2.5, end_dist=-2.5)
'POINT (2.5 0)'
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here