11import builtins
22from _typeshed import Incomplete , Unused
33from collections .abc import Callable , Sequence
4- from typing import Any , ClassVar , Literal , NoReturn , SupportsIndex , overload
4+ from typing import Any , ClassVar , Literal , NoReturn , SupportsIndex , TypeVar , overload
55from typing_extensions import Self , TypeAlias , deprecated
66
77import numpy as np
@@ -15,6 +15,8 @@ from shapely.geometry.base import BaseGeometry
1515from geopandas .base import _AffinityOrigin , _ConvertibleToCRS
1616from geopandas .sindex import SpatialIndex
1717
18+ _ScalarType = TypeVar ("_ScalarType" , bound = np .generic )
19+ _Array1D : TypeAlias = np .ndarray [tuple [int ], np .dtype [_ScalarType ]]
1820_ArrayOrGeom : TypeAlias = GeometryArray | ArrayLike | Geometry
1921
2022TransformerFromCRS = Transformer .from_crs
@@ -30,18 +32,18 @@ class GeometryDtype(ExtensionDtype):
3032
3133def isna (value : object ) -> bool : ...
3234def from_shapely (data , crs : _ConvertibleToCRS | None = None ) -> GeometryArray : ...
33- def to_shapely (geoms : GeometryArray ) -> NDArray [np .object_ ]: ...
35+ def to_shapely (geoms : GeometryArray ) -> _Array1D [np .object_ ]: ...
3436def from_wkb (
3537 data , crs : _ConvertibleToCRS | None = None , on_invalid : Literal ["raise" , "warn" , "ignore" ] = "raise"
3638) -> GeometryArray : ...
3739@overload
38- def to_wkb (geoms : GeometryArray , hex : Literal [False ] = False , ** kwargs ) -> NDArray [np .bytes_ ]: ...
40+ def to_wkb (geoms : GeometryArray , hex : Literal [False ] = False , ** kwargs ) -> _Array1D [np .bytes_ ]: ...
3941@overload
40- def to_wkb (geoms : GeometryArray , hex : Literal [True ], ** kwargs ) -> NDArray [np .str_ ]: ...
42+ def to_wkb (geoms : GeometryArray , hex : Literal [True ], ** kwargs ) -> _Array1D [np .str_ ]: ...
4143def from_wkt (
4244 data , crs : _ConvertibleToCRS | None = None , on_invalid : Literal ["raise" , "warn" , "ignore" ] = "raise"
4345) -> GeometryArray : ...
44- def to_wkt (geoms : GeometryArray , ** kwargs ) -> NDArray [np .str_ ]: ...
46+ def to_wkt (geoms : GeometryArray , ** kwargs ) -> _Array1D [np .str_ ]: ...
4547def points_from_xy (
4648 x : ArrayLike , y : ArrayLike , z : ArrayLike | None = None , crs : _ConvertibleToCRS | None = None
4749) -> GeometryArray : ...
@@ -64,44 +66,44 @@ class GeometryArray(ExtensionArray):
6466 def __getitem__ (self , idx : int | np .integer [Any ]) -> BaseGeometry : ... # Always 1-D, doesn't accept tuple
6567 @overload
6668 def __getitem__ (
67- self , idx : slice | Sequence [SupportsIndex ] | NDArray [np .bool_ ] | NDArray [np .integer [Any ]]
69+ self , idx : slice | Sequence [SupportsIndex ] | NDArray [np .bool ] | NDArray [np .integer [Any ]]
6870 ) -> GeometryArray : ...
6971 @overload
7072 def __getitem__ (
71- self , idx : int | np .integer [Any ] | slice | Sequence [int ] | NDArray [np .bool_ ] | NDArray [np .integer [Any ]]
73+ self , idx : int | np .integer [Any ] | slice | Sequence [int ] | NDArray [np .bool ] | NDArray [np .integer [Any ]]
7274 ) -> BaseGeometry | GeometryArray : ...
7375 def __setitem__ (self , key , value : _ArrayOrGeom | pd .DataFrame | pd .Series [Any ]) -> None : ...
7476 @property
75- def is_valid (self ) -> NDArray [np .bool_ ]: ...
76- def is_valid_reason (self ) -> NDArray [np .object_ ]: ...
77+ def is_valid (self ) -> _Array1D [np .bool ]: ...
78+ def is_valid_reason (self ) -> _Array1D [np .object_ ]: ...
7779 @property
78- def is_empty (self ) -> NDArray [np .bool_ ]: ...
80+ def is_empty (self ) -> _Array1D [np .bool ]: ...
7981 @property
80- def is_simple (self ) -> NDArray [np .bool_ ]: ...
82+ def is_simple (self ) -> _Array1D [np .bool ]: ...
8183 @property
82- def is_ring (self ) -> NDArray [np .bool_ ]: ...
84+ def is_ring (self ) -> _Array1D [np .bool ]: ...
8385 @property
84- def is_closed (self ) -> NDArray [np .bool_ ]: ...
86+ def is_closed (self ) -> _Array1D [np .bool ]: ...
8587 @property
86- def is_ccw (self ) -> NDArray [np .bool_ ]: ...
88+ def is_ccw (self ) -> _Array1D [np .bool ]: ...
8789 @property
88- def has_z (self ) -> NDArray [np .bool_ ]: ...
90+ def has_z (self ) -> _Array1D [np .bool ]: ...
8991 @property
90- def geom_type (self ) -> NDArray [np .int64 ]: ...
92+ def geom_type (self ) -> _Array1D [np .int64 ]: ...
9193 @property
92- def area (self ) -> NDArray [np .float64 ]: ...
94+ def area (self ) -> _Array1D [np .float64 ]: ...
9395 @property
94- def length (self ) -> NDArray [np .float64 ]: ...
95- def count_coordinates (self ) -> NDArray [np .int64 ]: ...
96- def count_geometries (self ) -> NDArray [np .int64 ]: ...
97- def count_interior_rings (self ) -> NDArray [np .int64 ]: ...
98- def get_precision (self ) -> NDArray [np .float64 ]: ...
99- def get_geometry (self , index : SupportsIndex | ArrayLike ) -> NDArray [np .object_ ]: ...
96+ def length (self ) -> _Array1D [np .float64 ]: ...
97+ def count_coordinates (self ) -> _Array1D [np .int64 ]: ...
98+ def count_geometries (self ) -> _Array1D [np .int64 ]: ...
99+ def count_interior_rings (self ) -> _Array1D [np .int64 ]: ...
100+ def get_precision (self ) -> _Array1D [np .float64 ]: ...
101+ def get_geometry (self , index : SupportsIndex | ArrayLike ) -> _Array1D [np .object_ ]: ...
100102 @property
101103 def boundary (self ) -> GeometryArray : ...
102104 @property
103105 def centroid (self ) -> GeometryArray : ...
104- def concave_hull (self , ratio : float , allow_holes : bool ) -> NDArray [np .object_ ]: ...
106+ def concave_hull (self , ratio : float , allow_holes : bool ) -> _Array1D [np .object_ ]: ...
105107 @property
106108 def convex_hull (self ) -> GeometryArray : ...
107109 @property
@@ -118,12 +120,12 @@ class GeometryArray(ExtensionArray):
118120 mitre_limit : float = 5.0 ,
119121 ) -> GeometryArray : ...
120122 @property
121- def interiors (self ) -> NDArray [np .object_ ]: ...
123+ def interiors (self ) -> _Array1D [np .object_ ]: ...
122124 def remove_repeated_points (self , tolerance : float | ArrayLike = 0.0 ) -> GeometryArray : ...
123125 def representative_point (self ) -> GeometryArray : ...
124126 def minimum_bounding_circle (self ) -> GeometryArray : ...
125- def minimum_bounding_radius (self ) -> NDArray [np .float64 ]: ...
126- def minimum_clearance (self ) -> NDArray [np .float64 ]: ...
127+ def minimum_bounding_radius (self ) -> _Array1D [np .float64 ]: ...
128+ def minimum_clearance (self ) -> _Array1D [np .float64 ]: ...
127129 def normalize (self ) -> GeometryArray : ...
128130 def make_valid (self ) -> GeometryArray : ...
129131 def reverse (self ) -> GeometryArray : ...
@@ -137,21 +139,21 @@ class GeometryArray(ExtensionArray):
137139 def set_precision (
138140 self , grid_size : float , mode : Literal ["valid_output" , "pointwise" , "keep_collapsed" , 0 , 1 , 2 ] = "valid_output"
139141 ) -> GeometryArray : ...
140- def covers (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
141- def covered_by (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
142- def contains (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
143- def contains_properly (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
144- def crosses (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
145- def disjoint (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
146- def geom_equals (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
147- def intersects (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
148- def overlaps (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
149- def touches (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
150- def within (self , other : _ArrayOrGeom ) -> NDArray [np .bool_ ]: ...
151- def dwithin (self , other : _ArrayOrGeom , distance : float ) -> NDArray [np .bool_ ]: ...
152- def geom_equals_exact (self , other : _ArrayOrGeom , tolerance : float | ArrayLike ) -> NDArray [np .bool_ ]: ...
142+ def covers (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
143+ def covered_by (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
144+ def contains (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
145+ def contains_properly (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
146+ def crosses (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
147+ def disjoint (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
148+ def geom_equals (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
149+ def intersects (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
150+ def overlaps (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
151+ def touches (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
152+ def within (self , other : _ArrayOrGeom ) -> _Array1D [np .bool ]: ...
153+ def dwithin (self , other : _ArrayOrGeom , distance : float ) -> _Array1D [np .bool ]: ...
154+ def geom_equals_exact (self , other : _ArrayOrGeom , tolerance : float | ArrayLike ) -> _Array1D [np .bool ]: ...
153155 @deprecated ("Use method `geom_equals_exact` instead." )
154- def geom_almost_equals (self , other : _ArrayOrGeom , decimal : float ) -> NDArray [np .bool_ ]: ...
156+ def geom_almost_equals (self , other : _ArrayOrGeom , decimal : float ) -> _Array1D [np .bool ]: ...
155157 def clip_by_rect (self , xmin : float , ymin : float , xmax : float , ymax : float ) -> GeometryArray : ...
156158 def difference (self , other : _ArrayOrGeom ) -> GeometryArray : ...
157159 def intersection (self , other : _ArrayOrGeom ) -> GeometryArray : ...
@@ -160,15 +162,15 @@ class GeometryArray(ExtensionArray):
160162 def shortest_line (self , other : _ArrayOrGeom ) -> GeometryArray : ...
161163 def snap (self , other : _ArrayOrGeom , tolerance : float | ArrayLike ) -> GeometryArray : ...
162164 def shared_paths (self , other : _ArrayOrGeom ) -> GeometryArray : ...
163- def distance (self , other : _ArrayOrGeom ) -> NDArray [np .float64 ]: ...
164- def hausdorff_distance (self , other : _ArrayOrGeom , ** kwargs : Any ) -> NDArray [np .float64 ]: ...
165- def frechet_distance (self , other : _ArrayOrGeom , ** kwargs ) -> NDArray [np .float64 ]: ...
165+ def distance (self , other : _ArrayOrGeom ) -> _Array1D [np .float64 ]: ...
166+ def hausdorff_distance (self , other : _ArrayOrGeom , ** kwargs : Any ) -> _Array1D [np .float64 ]: ...
167+ def frechet_distance (self , other : _ArrayOrGeom , ** kwargs ) -> _Array1D [np .float64 ]: ...
166168 def buffer (self , distance : float | ArrayLike , resolution : int = 16 , ** kwargs ) -> GeometryArray : ...
167169 def interpolate (self , distance , normalized : bool = False ) -> GeometryArray : ...
168170 def simplify (self , tolerance : float | ArrayLike , preserve_topology : bool = True ) -> GeometryArray : ...
169- def project (self , other : _ArrayOrGeom , normalized : bool = False ) -> NDArray [np .float64 ]: ...
170- def relate (self , other : _ArrayOrGeom ) -> NDArray [np .str_ ]: ...
171- def relate_pattern (self , other , pattern : str ) -> NDArray [np .bool_ ]: ...
171+ def project (self , other : _ArrayOrGeom , normalized : bool = False ) -> _Array1D [np .float64 ]: ...
172+ def relate (self , other : _ArrayOrGeom ) -> _Array1D [np .str_ ]: ...
173+ def relate_pattern (self , other , pattern : str ) -> _Array1D [np .bool ]: ...
172174 def unary_union (self ) -> BaseGeometry : ...
173175 def union_all (self , method : Literal ["coverage" , "unary" ] = "unary" ) -> BaseGeometry : ...
174176 def intersection_all (self ) -> BaseGeometry : ...
@@ -184,15 +186,15 @@ class GeometryArray(ExtensionArray):
184186 def to_crs (self , crs : _ConvertibleToCRS | None = None , epsg : int | None = None ) -> GeometryArray : ...
185187 def estimate_utm_crs (self , datum_name : str = "WGS 84" ) -> CRS : ...
186188 @property
187- def x (self ) -> NDArray [np .float64 ]: ...
189+ def x (self ) -> _Array1D [np .float64 ]: ...
188190 @property
189- def y (self ) -> NDArray [np .float64 ]: ...
191+ def y (self ) -> _Array1D [np .float64 ]: ...
190192 @property
191- def z (self ) -> NDArray [np .float64 ]: ...
193+ def z (self ) -> _Array1D [np .float64 ]: ...
192194 @property
193- def bounds (self ) -> NDArray [np .float64 ]: ...
195+ def bounds (self ) -> _Array1D [np .float64 ]: ...
194196 @property
195- def total_bounds (self ) -> NDArray [np .float64 ]: ...
197+ def total_bounds (self ) -> _Array1D [np .float64 ]: ...
196198 @property
197199 def size (self ) -> int : ...
198200 @property
@@ -214,17 +216,17 @@ class GeometryArray(ExtensionArray):
214216 copy : bool = True ,
215217 ) -> GeometryArray : ...
216218 def astype (self , dtype : DTypeLike , copy : bool = True ) -> GeometryArray | ExtensionArray | NDArray [Any ]: ...
217- def isna (self ) -> NDArray [np .bool_ ]: ...
219+ def isna (self ) -> _Array1D [np .bool ]: ...
218220 def value_counts (self , dropna : bool = True ) -> pd .Series [int ]: ...
219221 def unique (self ) -> GeometryArray : ...
220222 @property
221223 def nbytes (self ) -> int : ...
222224 def shift (self , periods : int = 1 , fill_value : Geometry | None = None ) -> GeometryArray : ... # type: ignore[override]
223225 def argmin (self , skipna : bool = True ) -> NoReturn : ...
224226 def argmax (self , skipna : bool = True ) -> NoReturn : ...
225- def __array__ (self , dtype : DTypeLike | None = None , copy : bool | None = None ) -> NDArray [np .object_ ]: ...
226- def __eq__ (self , other : object ) -> NDArray [np .bool_ ]: ... # type: ignore[override]
227- def __ne__ (self , other : object ) -> NDArray [np .bool_ ]: ... # type: ignore[override]
227+ def __array__ (self , dtype : DTypeLike | None = None , copy : bool | None = None ) -> _Array1D [np .object_ ]: ...
228+ def __eq__ (self , other : object ) -> _Array1D [np .bool ]: ... # type: ignore[override]
229+ def __ne__ (self , other : object ) -> _Array1D [np .bool ]: ... # type: ignore[override]
228230 def __contains__ (self , item : object ) -> bool : ...
229231
230232def transform (
0 commit comments