shapely.equals_exact#
- equals_exact(a, b, tolerance=0.0, *, normalize=False, **kwargs)#
Return True if the geometries are structurally equivalent within a given tolerance.
This method uses exact coordinate equality, which requires coordinates to be equal (within specified tolerance) and in the same order for all components (vertices, rings, or parts) of a geometry. This is in contrast with the
equals()
function which uses spatial (topological) equality and does not require all components to be in the same order. Because of this, it is possible forequals()
to beTrue
whileequals_exact()
isFalse
.The order of the coordinates can be normalized (by setting the normalize keyword to
True
) so that this function will returnTrue
when geometries are structurally equivalent but differ only in the ordering of vertices. However, this function will still returnFalse
if the order of interior rings within aPolygon
or the order of geometries within a multi geometry are different.- Parameters:
- a, bGeometry or array_like
Geometry or geometries to check.
- tolerancefloat or array_like (default: 0.)
The tolerance to use in the comparison.
- normalizebool, optional (default: False)
If True, normalize the two geometries so that the coordinates are in the same order.
Added in version 2.1.0.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
equals
Check if a and b are spatially (topologically) equal.
Examples
>>> import shapely >>> from shapely import Point, Polygon >>> point1 = Point(50, 50) >>> point2 = Point(50.1, 50.1) >>> shapely.equals_exact(point1, point2) False >>> shapely.equals_exact(point1, point2, tolerance=0.2) True >>> shapely.equals_exact(point1, None, tolerance=0.2) False
Difference between structural and spatial equality:
>>> polygon1 = Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]) >>> polygon2 = Polygon([(0, 0), (0, 1), (1, 1), (0, 0)]) >>> shapely.equals_exact(polygon1, polygon2) False >>> shapely.equals(polygon1, polygon2) True