Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@multithreading_enabled
def coverage_union(a, b, **kwargs):
"""Merges multiple polygons into one. This is an optimized version of
union which assumes the polygons to be non-overlapping.
Requires at least GEOS 3.8.0.
Parameters
----------
a : Geometry or array_like
b : Geometry or array_like
See also
--------
coverage_union_all
Examples
@multithreading_enabled
def coverage_union_all(geometries, axis=0, **kwargs):
"""Returns the union of multiple polygons of a geometry collection.
This is an optimized version of union which assumes the polygons
to be non-overlapping.
Requires at least GEOS 3.8.0.
Parameters
----------
geometries : array_like
axis : int
Axis along which the operation is performed. The default (zero)
performs the operation over the first dimension of the input array.
axis may be negative, in which case it counts from the last to the
first axis.
@multithreading_enabled
def is_simple(geometry, **kwargs):
"""Returns True if a Geometry has no anomalous geometric points, such as
self-intersections or self tangency.
Parameters
----------
geometry : Geometry or array_like
This function will return False for geometrycollections.
See also
--------
is_ring : Checks additionally if the geometry is closed.
Examples
--------
>>> is_simple(Geometry("POLYGON((1 1, 2 1, 2 2, 1 1))"))
@multithreading_enabled
def crosses(a, b, **kwargs):
"""Returns True if the intersection of two geometries spatially crosses.
That is: the geometries have some, but not all interior points in common.
The geometries must intersect and the intersection must have a
dimensionality less than the maximum dimension of the two input geometries.
Additionally, the intersection of the two geometries must not equal either
of the source geometries.
Parameters
----------
a, b : Geometry or array_like
Examples
--------
>>> line = Geometry("LINESTRING(0 0, 1 1)")
@multithreading_enabled
def get_type_id(geometry):
"""Returns the type ID of a geometry.
- None is -1
- POINT is 0
- LINESTRING is 1
- LINEARRING is 2
- POLYGON is 3
- MULTIPOINT is 4
- MULTILINESTRING is 5
- MULTIPOLYGON is 6
- GEOMETRYCOLLECTION is 7
Parameters
----------
geometry : Geometry or array_like
@multithreading_enabled
def covers(a, b, **kwargs):
"""Returns True if no point in geometry B is outside geometry A.
Parameters
----------
a, b : Geometry or array_like
See also
--------
covered_by : ``covers(A, B) == covered_by(B, A)``
Examples
--------
>>> line = Geometry("LINESTRING(0 0, 1 1)")
>>> covers(line, Geometry("POINT (0 0)"))
True
@multithreading_enabled
def get_num_coordinates(geometry):
"""Returns the total number of coordinates in a geometry.
Returns -1 for not-a-geometry values.
Parameters
----------
geometry : Geometry or array_like
Examples
--------
>>> get_num_coordinates(Geometry("POINT (0 0)"))
1
>>> get_num_coordinates(Geometry("POINT Z (0 0 0)"))
1
>>> get_num_coordinates(Geometry("GEOMETRYCOLLECTION (POINT(0 0), LINESTRING(0 0, 1 1))"))
@multithreading_enabled
def union_all(geometries, axis=0, **kwargs):
"""Returns the union of multiple geometries.
Parameters
----------
geometries : array_like
axis : int
Axis along which the operation is performed. The default (zero)
performs the operation over the first dimension of the input array.
axis may be negative, in which case it counts from the last to the
first axis.
See also
--------
union
@multithreading_enabled
def centroid(geometry, **kwargs):
"""Computes the geometric center (center-of-mass) of a geometry.
For multipoints this is computed as the mean of the input coordinates.
For multilinestrings the centroid is weighted by the length of each
line segment. For multipolygons the centroid is weighted by the area of
each polygon.
Parameters
----------
geometry : Geometry or array_like
Examples
--------
>>> centroid(Geometry("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"))
@multithreading_enabled
def hausdorff_distance(a, b, densify=None, **kwargs):
"""Compute the discrete Hausdorff distance between two geometries.
The Hausdorff distance is a measure of similarity: it is the greatest
distance between any point in A and the closest point in B. The discrete
distance is an approximation of this metric: only vertices are considered.
The parameter 'densify' makes this approximation less coarse by splitting
the line segments between vertices before computing the distance.
Parameters
----------
a, b : Geometry or array_like
densify : float, array_like or None
The value of densify is required to be between 0 and 1.
Examples