The shared_paths()
function in shapely.ops finds the shared paths between two linear geometries.
shapely.ops中的shared_paths()函数可以找到两个线性几何对象之间的共享路径。
Finds the shared paths between geom1 and geom2, where both geometries are LineStrings.
查找geom1和geom2之间的共享路径,其中两个几何对象都是LineString类型。
A GeometryCollection is returned with two elements. The first element is a MultiLineString containing shared paths with the same direction for both inputs. The second element is a MultiLineString containing shared paths with the opposite direction for the two inputs.
返回一个有两个元素的几何集合。第一个元素是一个MultiLineString,包含两个输入方向相同的共享路径。第二个元素是一个MultiLineString,包含两个输入方向相反的共享路径。
New in version 1.6.0
>>> from shapely.ops import shared_paths
>>> g1 = LineString([(0, 0), (10, 0), (10, 5), (20, 5)])
>>> g2 = LineString([(5, 0), (30, 0), (30, 5), (0, 5)])
>>> forward, backward = shared_paths(g1, g2).geoms
>>> forward
<MULTILINESTRING ((5 0, 10 0))>
>>> backward
<MULTILINESTRING ((10 5, 20 5))>