shapely 2.1.2__cp314-cp314-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shapely/__init__.py +48 -0
- shapely/_coverage.py +168 -0
- shapely/_enum.py +23 -0
- shapely/_geometry.py +1027 -0
- shapely/_geometry_helpers.cp314-win32.pyd +0 -0
- shapely/_geos.cp314-win32.pyd +0 -0
- shapely/_geos.pxd +57 -0
- shapely/_pygeos_api.pxd +58 -0
- shapely/_ragged_array.py +475 -0
- shapely/_version.py +21 -0
- shapely/affinity.py +266 -0
- shapely/algorithms/__init__.py +1 -0
- shapely/algorithms/_oriented_envelope.py +56 -0
- shapely/algorithms/cga.py +50 -0
- shapely/algorithms/polylabel.py +43 -0
- shapely/conftest.py +70 -0
- shapely/constructive.py +1552 -0
- shapely/coordinates.py +335 -0
- shapely/coords.py +119 -0
- shapely/creation.py +831 -0
- shapely/decorators.py +183 -0
- shapely/errors.py +79 -0
- shapely/geometry/__init__.py +27 -0
- shapely/geometry/base.py +1138 -0
- shapely/geometry/collection.py +58 -0
- shapely/geometry/geo.py +143 -0
- shapely/geometry/linestring.py +211 -0
- shapely/geometry/multilinestring.py +95 -0
- shapely/geometry/multipoint.py +104 -0
- shapely/geometry/multipolygon.py +125 -0
- shapely/geometry/point.py +166 -0
- shapely/geometry/polygon.py +345 -0
- shapely/geos.py +17 -0
- shapely/io.py +408 -0
- shapely/lib.cp314-win32.pyd +0 -0
- shapely/linear.py +236 -0
- shapely/measurement.py +355 -0
- shapely/ops.py +720 -0
- shapely/plotting.py +222 -0
- shapely/predicates.py +1350 -0
- shapely/prepared.py +74 -0
- shapely/set_operations.py +787 -0
- shapely/speedups.py +39 -0
- shapely/strtree.py +550 -0
- shapely/testing.py +208 -0
- shapely/tests/__init__.py +0 -0
- shapely/tests/common.py +285 -0
- shapely/tests/geometry/__init__.py +0 -0
- shapely/tests/geometry/test_collection.py +95 -0
- shapely/tests/geometry/test_coords.py +127 -0
- shapely/tests/geometry/test_decimal.py +117 -0
- shapely/tests/geometry/test_emptiness.py +98 -0
- shapely/tests/geometry/test_equality.py +284 -0
- shapely/tests/geometry/test_format.py +118 -0
- shapely/tests/geometry/test_geometry_base.py +369 -0
- shapely/tests/geometry/test_hash.py +28 -0
- shapely/tests/geometry/test_linestring.py +232 -0
- shapely/tests/geometry/test_multi.py +11 -0
- shapely/tests/geometry/test_multilinestring.py +77 -0
- shapely/tests/geometry/test_multipoint.py +93 -0
- shapely/tests/geometry/test_multipolygon.py +156 -0
- shapely/tests/geometry/test_point.py +201 -0
- shapely/tests/geometry/test_polygon.py +460 -0
- shapely/tests/legacy/__init__.py +0 -0
- shapely/tests/legacy/conftest.py +12 -0
- shapely/tests/legacy/test_affinity.py +308 -0
- shapely/tests/legacy/test_box.py +20 -0
- shapely/tests/legacy/test_buffer.py +173 -0
- shapely/tests/legacy/test_cga.py +51 -0
- shapely/tests/legacy/test_clip_by_rect.py +119 -0
- shapely/tests/legacy/test_create_inconsistent_dimensionality.py +217 -0
- shapely/tests/legacy/test_delaunay.py +32 -0
- shapely/tests/legacy/test_empty_polygons.py +22 -0
- shapely/tests/legacy/test_equality.py +24 -0
- shapely/tests/legacy/test_geointerface.py +118 -0
- shapely/tests/legacy/test_invalid_geometries.py +26 -0
- shapely/tests/legacy/test_linear_referencing.py +72 -0
- shapely/tests/legacy/test_linemerge.py +43 -0
- shapely/tests/legacy/test_locale.py +54 -0
- shapely/tests/legacy/test_make_valid.py +15 -0
- shapely/tests/legacy/test_mapping.py +14 -0
- shapely/tests/legacy/test_minimum_clearance.py +30 -0
- shapely/tests/legacy/test_ndarrays.py +42 -0
- shapely/tests/legacy/test_nearest.py +18 -0
- shapely/tests/legacy/test_operations.py +124 -0
- shapely/tests/legacy/test_operators.py +60 -0
- shapely/tests/legacy/test_orient.py +92 -0
- shapely/tests/legacy/test_parallel_offset.py +60 -0
- shapely/tests/legacy/test_persist.py +48 -0
- shapely/tests/legacy/test_pickle.py +81 -0
- shapely/tests/legacy/test_polygonize.py +43 -0
- shapely/tests/legacy/test_polylabel.py +85 -0
- shapely/tests/legacy/test_predicates.py +95 -0
- shapely/tests/legacy/test_prepared.py +65 -0
- shapely/tests/legacy/test_products_z.py +13 -0
- shapely/tests/legacy/test_shape.py +63 -0
- shapely/tests/legacy/test_shared_paths.py +45 -0
- shapely/tests/legacy/test_singularity.py +15 -0
- shapely/tests/legacy/test_snap.py +24 -0
- shapely/tests/legacy/test_split.py +285 -0
- shapely/tests/legacy/test_substring.py +220 -0
- shapely/tests/legacy/test_svg.py +213 -0
- shapely/tests/legacy/test_transform.py +80 -0
- shapely/tests/legacy/test_union.py +66 -0
- shapely/tests/legacy/test_validation.py +9 -0
- shapely/tests/legacy/test_vectorized.py +108 -0
- shapely/tests/legacy/test_voronoi_diagram.py +129 -0
- shapely/tests/legacy/test_wkb.py +176 -0
- shapely/tests/legacy/test_wkt.py +61 -0
- shapely/tests/legacy/threading_test.py +44 -0
- shapely/tests/test_constructive.py +1390 -0
- shapely/tests/test_coordinates.py +422 -0
- shapely/tests/test_coverage.py +249 -0
- shapely/tests/test_creation.py +742 -0
- shapely/tests/test_creation_indices.py +585 -0
- shapely/tests/test_decorators.py +138 -0
- shapely/tests/test_geometry.py +739 -0
- shapely/tests/test_io.py +1351 -0
- shapely/tests/test_linear.py +224 -0
- shapely/tests/test_measurement.py +344 -0
- shapely/tests/test_misc.py +189 -0
- shapely/tests/test_plotting.py +121 -0
- shapely/tests/test_predicates.py +414 -0
- shapely/tests/test_ragged_array.py +665 -0
- shapely/tests/test_set_operations.py +481 -0
- shapely/tests/test_strtree.py +1964 -0
- shapely/tests/test_testing.py +97 -0
- shapely/validation.py +55 -0
- shapely/vectorized/__init__.py +91 -0
- shapely/wkb.py +70 -0
- shapely/wkt.py +82 -0
- shapely-2.1.2.dist-info/DELVEWHEEL +2 -0
- shapely-2.1.2.dist-info/METADATA +208 -0
- shapely-2.1.2.dist-info/RECORD +142 -0
- shapely-2.1.2.dist-info/WHEEL +5 -0
- shapely-2.1.2.dist-info/licenses/LICENSE.txt +29 -0
- shapely-2.1.2.dist-info/licenses/LICENSE_GEOS +509 -0
- shapely-2.1.2.dist-info/licenses/LICENSE_win32 +26 -0
- shapely-2.1.2.dist-info/top_level.txt +1 -0
- shapely.libs/geos-124ff73fe281c3c4533468bb6828afbf.dll +0 -0
- shapely.libs/geos_c-53a4ee54c8f304fa169555cc76fdac73.dll +0 -0
- shapely.libs/msvcp140-980a2317427450c632204e17fd95e4b7.dll +0 -0
shapely/__init__.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Manipulation and analysis of geometric objects in the Cartesian plane."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# start delvewheel patch
|
|
5
|
+
def _delvewheel_patch_1_11_1():
|
|
6
|
+
import os
|
|
7
|
+
if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'shapely.libs'))):
|
|
8
|
+
os.add_dll_directory(libs_dir)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_delvewheel_patch_1_11_1()
|
|
12
|
+
del _delvewheel_patch_1_11_1
|
|
13
|
+
# end delvewheel patch
|
|
14
|
+
|
|
15
|
+
from shapely.lib import GEOSException
|
|
16
|
+
from shapely.lib import Geometry
|
|
17
|
+
from shapely.lib import geos_version, geos_version_string
|
|
18
|
+
from shapely.lib import geos_capi_version, geos_capi_version_string
|
|
19
|
+
from shapely.errors import setup_signal_checks
|
|
20
|
+
from shapely._geometry import *
|
|
21
|
+
from shapely.creation import *
|
|
22
|
+
from shapely.constructive import *
|
|
23
|
+
from shapely.predicates import *
|
|
24
|
+
from shapely.measurement import *
|
|
25
|
+
from shapely.set_operations import *
|
|
26
|
+
from shapely.linear import *
|
|
27
|
+
from shapely.coordinates import *
|
|
28
|
+
from shapely.strtree import *
|
|
29
|
+
from shapely.io import *
|
|
30
|
+
from shapely._coverage import *
|
|
31
|
+
|
|
32
|
+
# Submodule always needs to be imported to ensure Geometry subclasses are registered
|
|
33
|
+
from shapely.geometry import (
|
|
34
|
+
Point,
|
|
35
|
+
LineString,
|
|
36
|
+
Polygon,
|
|
37
|
+
MultiPoint,
|
|
38
|
+
MultiLineString,
|
|
39
|
+
MultiPolygon,
|
|
40
|
+
GeometryCollection,
|
|
41
|
+
LinearRing,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
from shapely import _version
|
|
45
|
+
|
|
46
|
+
__version__ = _version.get_versions()["version"]
|
|
47
|
+
|
|
48
|
+
setup_signal_checks()
|
shapely/_coverage.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from shapely import Geometry, GeometryType, lib
|
|
4
|
+
from shapely._geometry import get_parts
|
|
5
|
+
from shapely.decorators import multithreading_enabled, requires_geos
|
|
6
|
+
|
|
7
|
+
__all__ = ["coverage_invalid_edges", "coverage_is_valid", "coverage_simplify"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@requires_geos("3.12.0")
|
|
11
|
+
@multithreading_enabled
|
|
12
|
+
def coverage_is_valid(geometry, gap_width=0.0, **kwargs):
|
|
13
|
+
"""Verify if a coverage is valid.
|
|
14
|
+
|
|
15
|
+
The coverage is represented by an array of polygonal geometries with
|
|
16
|
+
exactly matching edges and no overlap.
|
|
17
|
+
|
|
18
|
+
A valid coverage may contain holes (regions of no coverage). However,
|
|
19
|
+
sometimes it might be desirable to detect narrow gaps as invalidities in
|
|
20
|
+
the coverage. The `gap_width` parameter allows to specify the maximum
|
|
21
|
+
width of gaps to detect. When gaps are detected, this function will
|
|
22
|
+
return False and the `coverage_invalid_edges` function can be used to
|
|
23
|
+
find the edges of those gaps.
|
|
24
|
+
|
|
25
|
+
Geometries that are not Polygon or MultiPolygon are ignored.
|
|
26
|
+
|
|
27
|
+
.. versionadded:: 2.1.0
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
geometry : array_like
|
|
32
|
+
Array of geometries to verify.
|
|
33
|
+
gap_width : float, default 0.0
|
|
34
|
+
The maximum width of gaps to detect.
|
|
35
|
+
**kwargs
|
|
36
|
+
See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
bool
|
|
41
|
+
|
|
42
|
+
See Also
|
|
43
|
+
--------
|
|
44
|
+
coverage_invalid_edges, coverage_simplify
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
geometries = np.asarray(geometry)
|
|
48
|
+
# we always consider the full array as a single coverage -> ravel the input
|
|
49
|
+
# to pass a 1D array
|
|
50
|
+
return lib.coverage_is_valid(geometries.ravel(order="K"), gap_width, **kwargs)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@requires_geos("3.12.0")
|
|
54
|
+
@multithreading_enabled
|
|
55
|
+
def coverage_invalid_edges(geometry, gap_width=0.0, **kwargs):
|
|
56
|
+
"""Verify if a coverage is valid and return invalid edges.
|
|
57
|
+
|
|
58
|
+
This functions returns linear indicators showing the location of invalid
|
|
59
|
+
edges (if any) in each polygon in the input array.
|
|
60
|
+
|
|
61
|
+
The coverage is represented by an array of polygonal geometries with
|
|
62
|
+
exactly matching edges and no overlap.
|
|
63
|
+
|
|
64
|
+
A valid coverage may contain holes (regions of no coverage). However,
|
|
65
|
+
sometimes it might be desirable to detect narrow gaps as invalidities in
|
|
66
|
+
the coverage. The `gap_width` parameter allows to specify the maximum
|
|
67
|
+
width of gaps to detect. When gaps are detected, the `coverage_is_valid`
|
|
68
|
+
function will return False and this function can be used to find the
|
|
69
|
+
edges of those gaps.
|
|
70
|
+
|
|
71
|
+
Geometries that are not Polygon or MultiPolygon are ignored.
|
|
72
|
+
|
|
73
|
+
.. versionadded:: 2.1.0
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
geometry : array_like
|
|
78
|
+
Array of geometries to verify.
|
|
79
|
+
gap_width : float, default 0.0
|
|
80
|
+
The maximum width of gaps to detect.
|
|
81
|
+
**kwargs
|
|
82
|
+
See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
numpy.ndarray | shapely.Geometry
|
|
87
|
+
|
|
88
|
+
See Also
|
|
89
|
+
--------
|
|
90
|
+
coverage_is_valid, coverage_simplify
|
|
91
|
+
|
|
92
|
+
"""
|
|
93
|
+
geometries = np.asarray(geometry)
|
|
94
|
+
# we always consider the full array as a single coverage -> ravel the input
|
|
95
|
+
# to pass a 1D array
|
|
96
|
+
return lib.coverage_invalid_edges(geometries.ravel(order="K"), gap_width, **kwargs)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@requires_geos("3.12.0")
|
|
100
|
+
@multithreading_enabled
|
|
101
|
+
def coverage_simplify(geometry, tolerance, *, simplify_boundary=True):
|
|
102
|
+
"""Return a simplified version of an input geometry using coverage simplification.
|
|
103
|
+
|
|
104
|
+
Assumes that the geometry forms a polygonal coverage. Under this assumption, the
|
|
105
|
+
function simplifies the edges using the Visvalingam-Whyatt algorithm, while
|
|
106
|
+
preserving a valid coverage. In the most simplified case, polygons are reduced to
|
|
107
|
+
triangles.
|
|
108
|
+
|
|
109
|
+
A collection of valid polygons is considered a coverage if the polygons are:
|
|
110
|
+
|
|
111
|
+
* **Non-overlapping** - polygons do not overlap (their interiors do not intersect)
|
|
112
|
+
* **Edge-Matched** - vertices along shared edges are identical
|
|
113
|
+
|
|
114
|
+
The function allows simplification of all edges including the outer boundaries of
|
|
115
|
+
the coverage or simplification of only the inner (shared) edges.
|
|
116
|
+
|
|
117
|
+
If there are other geometry types than Polygons or MultiPolygons present,
|
|
118
|
+
the function will raise an error.
|
|
119
|
+
|
|
120
|
+
If the geometry is polygonal but does not form a valid coverage due to overlaps,
|
|
121
|
+
it will be simplified but it may result in invalid topology.
|
|
122
|
+
|
|
123
|
+
.. versionadded:: 2.1.0
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
geometry : Geometry or array_like
|
|
128
|
+
tolerance : float or array_like
|
|
129
|
+
The degree of simplification roughly equal to the square root of the area
|
|
130
|
+
of triangles that will be removed.
|
|
131
|
+
simplify_boundary : bool, optional
|
|
132
|
+
By default (True), simplifies both internal edges of the coverage as well
|
|
133
|
+
as its boundary. If set to False, only simplifies internal edges.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
numpy.ndarray | shapely.Geometry
|
|
138
|
+
|
|
139
|
+
See Also
|
|
140
|
+
--------
|
|
141
|
+
coverage_is_valid, coverage_invalid_edges
|
|
142
|
+
|
|
143
|
+
Examples
|
|
144
|
+
--------
|
|
145
|
+
>>> import shapely
|
|
146
|
+
>>> from shapely import Polygon
|
|
147
|
+
>>> poly = Polygon([(0, 0), (20, 0), (20, 10), (10, 5), (0, 10), (0, 0)])
|
|
148
|
+
>>> shapely.coverage_simplify(poly, tolerance=2)
|
|
149
|
+
<POLYGON ((0 0, 20 0, 20 10, 10 5, 0 10, 0 0))>
|
|
150
|
+
"""
|
|
151
|
+
scalar = False
|
|
152
|
+
if isinstance(geometry, Geometry):
|
|
153
|
+
scalar = True
|
|
154
|
+
|
|
155
|
+
geometries = np.asarray(geometry)
|
|
156
|
+
shape = geometries.shape
|
|
157
|
+
geometries = geometries.ravel()
|
|
158
|
+
|
|
159
|
+
# create_collection acts on the inner axis
|
|
160
|
+
collections = lib.create_collection(
|
|
161
|
+
geometries, np.intc(GeometryType.GEOMETRYCOLLECTION)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
simplified = lib.coverage_simplify(collections, tolerance, simplify_boundary)
|
|
165
|
+
parts = get_parts(simplified).reshape(shape)
|
|
166
|
+
if scalar:
|
|
167
|
+
return parts.item()
|
|
168
|
+
return parts
|
shapely/_enum.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ParamEnum(IntEnum):
|
|
5
|
+
"""Wraps IntEnum to provide validation of a requested item.
|
|
6
|
+
|
|
7
|
+
Intended for enums used for function parameters.
|
|
8
|
+
|
|
9
|
+
Use enum.get_value(item) for this behavior instead of builtin enum[item].
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def get_value(cls, item):
|
|
14
|
+
"""Validate item and raise a ValueError with valid options if not present."""
|
|
15
|
+
try:
|
|
16
|
+
return cls[item].value
|
|
17
|
+
except KeyError:
|
|
18
|
+
valid_options = {e.name for e in cls}
|
|
19
|
+
raise ValueError(
|
|
20
|
+
"'{}' is not a valid option, must be one of '{}'".format(
|
|
21
|
+
item, "', '".join(valid_options)
|
|
22
|
+
)
|
|
23
|
+
)
|