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.

geometryGeometry or array_like

Geometries are changed in place


For other keyword-only arguments, see the NumPy ufunc docs.

See also


Identify whether a geometry is prepared already.


Destroy the prepared part of a geometry.


>>> 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]