The split()
function in shapely.ops splits a geometry by another geometry.
shapely.ops中的split()函数将一个几何对象与另一个几何对象执行分割操作。
Splits a geometry by another geometry and returns a collection of geometries. This function is the theoretical opposite of the union of the split geometry parts. If the splitter does not split the geometry, a collection with a single geometry equal to the input geometry is returned.
将一个几何对象与另一个几何对象分割,并返回一个几何集合。这个函数在理论上与分割后的几何对象部分的联合操作相反。如果分割器没有分割几何对象,则返回一个与输入几何对象相同的单一几何集合。
The function supports:
该函数支持
- Splitting a (Multi)LineString by a (Multi)Point or (Multi)LineString or (Multi)Polygon boundary(用点、复合点或线、复合线或多边形、复合多边形边界分割线或复合线)
- Splitting a (Multi)Polygon by a LineString(通过一个线要素分割一个多边形要素)
It may be convenient to snap the splitter with low tolerance to the geometry. For example in the case of splitting a line by a point, the point must be exactly on the line, for the line to be correctly split. When splitting a line by a polygon, the boundary of the polygon is used for the operation. When splitting a line by another line, a ValueError is raised if the two overlap at some segment.
以较低的容差分割几何对象可能是很方便的。例如,在用一个点分割线的情况下,该点必须正好在直线上,才能正确分割直线。当用多边形分割一条线时,多边形的边界被用于运算。当用另一条线分割一条线时,如果这两条线在某些段上重叠,就会产生ValueError。
New in version 1.6.0
>>> from shapely.ops import split
>>> pt = Point((1, 1))
>>> line = LineString([(0,0), (2,2)])
>>> result = split(line, pt)
>>> result
<GEOMETRYCOLLECTION (LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2))>