shapely.prepare#
- prepare(geometry, **kwargs)#
Prepare a geometry, improving performance of other operations.
A prepared geometry is a normal geometry with added information such as an index on the line segments. This improves the performance of the following operations: contains, contains_properly, covered_by, covers, crosses, disjoint, intersects, overlaps, touches, and within.
Note that if a prepared geometry is modified, the newly created Geometry object is not prepared. In that case,
prepare
should be called again.This function does not recompute previously prepared geometries; it is efficient to call this function on an array that partially contains prepared geometries.
This function does not return any values; geometries are modified in place.
- Parameters:
- geometryGeometry or array_like
Geometries are changed in place
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
is_prepared
Identify whether a geometry is prepared already.
destroy_prepared
Destroy the prepared part of a geometry.
Examples
>>> from shapely import Point, buffer, prepare, contains_properly >>> poly = buffer(Point(1.0, 1.0), 1) >>> prepare(poly) >>> contains_properly(poly, [Point(0.0, 0.0), Point(0.5, 0.5)]).tolist() [False, True]