diff --git a/stubs/geopandas/METADATA.toml b/stubs/geopandas/METADATA.toml index 653120efd9b8..a5e93be804e9 100644 --- a/stubs/geopandas/METADATA.toml +++ b/stubs/geopandas/METADATA.toml @@ -1,4 +1,4 @@ -version = "1.1.4" +version = "1.2.0" upstream-repository = "https://github.com/geopandas/geopandas" # Requires a version of numpy with a `py.typed` file dependencies = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] diff --git a/stubs/geopandas/geopandas/_config.pyi b/stubs/geopandas/geopandas/_config.pyi index c60381fdc8ec..eaf618473bc7 100644 --- a/stubs/geopandas/geopandas/_config.pyi +++ b/stubs/geopandas/geopandas/_config.pyi @@ -16,6 +16,5 @@ class Options: def __getattr__(self, key: str) -> Any: ... display_precision: Option -use_pygeos: Option io_engine: Option options: Options diff --git a/stubs/geopandas/geopandas/array.pyi b/stubs/geopandas/geopandas/array.pyi index 0d0d745aefc6..818dede50df4 100644 --- a/stubs/geopandas/geopandas/array.pyi +++ b/stubs/geopandas/geopandas/array.pyi @@ -170,17 +170,17 @@ class GeometryArray(ExtensionArray): def geom_equals_exact(self, other: _ArrayOrGeom, tolerance: float | ArrayLike) -> _Array1D[np.bool_]: ... def geom_equals_identical(self, other: _ArrayOrGeom) -> _Array1D[np.bool_]: ... def clip_by_rect(self, xmin: float, ymin: float, xmax: float, ymax: float) -> GeometryArray: ... - def difference(self, other: _ArrayOrGeom) -> GeometryArray: ... - def intersection(self, other: _ArrayOrGeom) -> GeometryArray: ... - def symmetric_difference(self, other: _ArrayOrGeom) -> GeometryArray: ... - def union(self, other: _ArrayOrGeom) -> GeometryArray: ... + def difference(self, other: _ArrayOrGeom, grid_size: float | None = None) -> GeometryArray: ... + def intersection(self, other: _ArrayOrGeom, grid_size: float | None = None) -> GeometryArray: ... + def symmetric_difference(self, other: _ArrayOrGeom, grid_size: float | None = None) -> GeometryArray: ... + def union(self, other: _ArrayOrGeom, grid_size: float | None = None) -> GeometryArray: ... def shortest_line(self, other: _ArrayOrGeom) -> GeometryArray: ... def snap(self, other: _ArrayOrGeom, tolerance: float | ArrayLike) -> GeometryArray: ... def shared_paths(self, other: _ArrayOrGeom) -> GeometryArray: ... def distance(self, other: _ArrayOrGeom) -> _Array1D[np.float64]: ... def hausdorff_distance(self, other: _ArrayOrGeom, **kwargs) -> _Array1D[np.float64]: ... def frechet_distance(self, other: _ArrayOrGeom, **kwargs) -> _Array1D[np.float64]: ... - def buffer(self, distance: float | ArrayLike, resolution: int = 16, **kwargs) -> GeometryArray: ... + def buffer(self, distance: float | ArrayLike, quad_segs: int | None = None, **kwargs) -> GeometryArray: ... def interpolate(self, distance: float | ArrayLike, normalized: bool = False) -> GeometryArray: ... # type: ignore[override] def simplify(self, tolerance: float | ArrayLike, preserve_topology: bool = True) -> GeometryArray: ... def simplify_coverage(self, tolerance: float | ArrayLike, simplify_boundary: bool = True) -> GeometryArray: ... @@ -247,6 +247,8 @@ class GeometryArray(ExtensionArray): def shift(self, periods: int = 1, fill_value: Geometry | None = None) -> GeometryArray: ... # type: ignore[override] def argmin(self, skipna: bool = True) -> Never: ... def argmax(self, skipna: bool = True) -> Never: ... + def all(self, *, skipna: bool = True) -> bool: ... + def any(self, *, skipna: bool = True) -> bool: ... def __array__(self, dtype: DTypeLike | None = None, copy: bool | None = None) -> _Array1D[np.object_]: ... def __eq__(self, other: object) -> _Array1D[np.bool_]: ... # type: ignore[override] def __ne__(self, other: object) -> _Array1D[np.bool_]: ... # type: ignore[override] diff --git a/stubs/geopandas/geopandas/base.pyi b/stubs/geopandas/geopandas/base.pyi index 1cb2dc1c8420..8bc0a32428a8 100644 --- a/stubs/geopandas/geopandas/base.pyi +++ b/stubs/geopandas/geopandas/base.pyi @@ -165,10 +165,14 @@ class GeoPandasBase: def frechet_distance( self, other: GeoSeries | Geometry, align: bool | None = None, densify: float | ArrayLike | None = None ) -> pd.Series[float]: ... - def difference(self, other: GeoSeries | Geometry, align: bool | None = None) -> GeoSeries: ... - def symmetric_difference(self, other: GeoSeries | Geometry, align: bool | None = None) -> GeoSeries: ... - def union(self, other: GeoSeries | Geometry, align: bool | None = None) -> GeoSeries: ... - def intersection(self, other: GeoSeries | Geometry, align: bool | None = None) -> GeoSeries: ... + def difference(self, other: GeoSeries | Geometry, align: bool | None = None, grid_size: float | None = None) -> GeoSeries: ... + def symmetric_difference( + self, other: GeoSeries | Geometry, align: bool | None = None, grid_size: float | None = None + ) -> GeoSeries: ... + def union(self, other: GeoSeries | Geometry, align: bool | None = None, grid_size: float | None = None) -> GeoSeries: ... + def intersection( + self, other: GeoSeries | Geometry, align: bool | None = None, grid_size: float | None = None + ) -> GeoSeries: ... def clip_by_rect(self, xmin: float, ymin: float, xmax: float, ymax: float) -> GeoSeries: ... def shortest_line(self, other: GeoSeries | Geometry, align: bool | None = None) -> GeoSeries: ... def snap(self, other: GeoSeries | Geometry, tolerance: float | ArrayLike, align: bool | None = None) -> GeoSeries: ... @@ -181,16 +185,32 @@ class GeoPandasBase: def sindex(self) -> SpatialIndex: ... @property def has_sindex(self) -> bool: ... + + @overload + def buffer( + self, + distance: float | ArrayLike, + quad_segs: int | None = None, + cap_style: Literal["round", "square", "flat"] = "round", + join_style: Literal["round", "mitre", "bevel"] = "round", + mitre_limit: float = 5.0, + single_sided: bool = False, + **kwargs, + ) -> GeoSeries: ... + @overload + @deprecated("The `resolution` argument to `buffer` is deprecated, use `quad_segs` instead.") def buffer( self, distance: float | ArrayLike, - resolution: int = 16, + *, + resolution: int, cap_style: Literal["round", "square", "flat"] = "round", join_style: Literal["round", "mitre", "bevel"] = "round", mitre_limit: float = 5.0, single_sided: bool = False, **kwargs, ) -> GeoSeries: ... + def simplify(self, tolerance: float | ArrayLike, preserve_topology: bool = True) -> GeoSeries: ... def simplify_coverage(self, tolerance: float | ArrayLike, *, simplify_boundary: bool = True) -> GeoSeries: ... def relate(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[str]: ... @@ -214,28 +234,22 @@ class GeoPandasBase: def hilbert_distance( self, total_bounds: tuple[float, float, float, float] | Iterable[float] | None = None, level: int = 16 ) -> pd.Series[int]: ... - - @overload def sample_points( self, size: int | ArrayLike, method: str = "uniform", - seed: None = None, rng: int | ArrayLike | SeedSequence | BitGenerator | RandomGenerator | None = None, **kwargs, ) -> GeoSeries: ... - @overload - @deprecated("Parameter `seed` is deprecated. Use `rng` instead.") - def sample_points( + def make_grid( self, - size: int | ArrayLike, - method: str = "uniform", - *, - seed: int | ArrayLike | SeedSequence | BitGenerator | RandomGenerator, - rng: int | ArrayLike | SeedSequence | BitGenerator | RandomGenerator | None = None, - **kwargs, + cell_size: float, + grid_type: Literal["square", "hexagon"] = "square", + feature_type: Literal["centers", "corners", "polygons"] = "polygons", + offset: tuple[float, float] | None = None, + intersect: bool = True, + flat_topped: bool = False, ) -> GeoSeries: ... - def build_area(self, node: bool = True) -> GeoSeries: ... @overload diff --git a/stubs/geopandas/geopandas/plotting.pyi b/stubs/geopandas/geopandas/plotting.pyi index 4d08e752d64c..25e55071d3a7 100644 --- a/stubs/geopandas/geopandas/plotting.pyi +++ b/stubs/geopandas/geopandas/plotting.pyi @@ -1,3 +1,4 @@ +import os from _typeshed import Incomplete from collections.abc import Collection, Hashable, Iterable, Mapping, Sequence from typing import Literal, TypeAlias, overload @@ -14,6 +15,9 @@ from .geodataframe import GeoDataFrame from .geoseries import GeoSeries _ColorOrColors: TypeAlias = ColorType | Sequence[ColorType] | ArrayLike +ColumnLike: TypeAlias = Hashable | pd.Series | pd.Index | pd.Categorical | NDArray[Incomplete] | Sequence[Incomplete] | None +# Also accepts xyzservices.TileProvider and rasterio.io.MemoryFile +_Tiles: TypeAlias = bool | str | os.PathLike[str] | Incomplete def plot_series( s: GeoSeries, @@ -23,6 +27,9 @@ def plot_series( figsize: tuple[float, float] | None = None, aspect: Literal["auto", "equal"] | float | None = "auto", autolim: bool = True, + tiles: _Tiles = False, + attr: str | None = None, + add_labels: bool = True, *, # Extracted from `**style_kwds` vmin: float = ..., @@ -35,7 +42,7 @@ def plot_series( # IMPORTANT: keep roughly in sync with `GeoplotAccessor` methods below def plot_dataframe( df: GeoDataFrame, - column: Hashable | None = None, + column: ColumnLike = None, cmap: str | Colormap | None = None, color: _ColorOrColors | None = None, ax: Axes | None = None, @@ -54,6 +61,9 @@ def plot_dataframe( missing_kwds: dict[str, Incomplete] | None = None, aspect: Literal["auto", "equal"] | float | None = "auto", autolim: bool = True, + tiles: _Tiles = False, + attr: str | None = None, + add_labels: bool = True, *, # Extracted from `**style_kwds` norm: Normalize | None = None, @@ -197,7 +207,7 @@ class GeoplotAccessor(PlotAccessor): @overload def __call__( self, - column: Hashable | pd.Series | pd.Index | NDArray | None = None, + column: ColumnLike = None, cmap: str | Colormap | None = None, color: _ColorOrColors | None = None, ax: Axes | None = None, @@ -229,7 +239,7 @@ class GeoplotAccessor(PlotAccessor): def geo( self, - column: Hashable | pd.Series | pd.Index | NDArray | None = None, + column: ColumnLike = None, cmap: str | Colormap | None = None, color: _ColorOrColors | None = None, ax: Axes | None = None, diff --git a/stubs/geopandas/geopandas/tools/__init__.pyi b/stubs/geopandas/geopandas/tools/__init__.pyi index a194399c228c..fdd90aef6f1d 100644 --- a/stubs/geopandas/geopandas/tools/__init__.pyi +++ b/stubs/geopandas/geopandas/tools/__init__.pyi @@ -1,7 +1,8 @@ from .clip import clip as clip from .geocoding import geocode as geocode, reverse_geocode as reverse_geocode +from .make_grid import make_grid as make_grid from .overlay import overlay as overlay from .sjoin import sjoin as sjoin, sjoin_nearest as sjoin_nearest from .util import collect as collect -__all__ = ["collect", "geocode", "overlay", "reverse_geocode", "sjoin", "sjoin_nearest", "clip"] +__all__ = ["collect", "geocode", "make_grid", "overlay", "reverse_geocode", "sjoin", "sjoin_nearest", "clip"] diff --git a/stubs/geopandas/geopandas/tools/make_grid.pyi b/stubs/geopandas/geopandas/tools/make_grid.pyi new file mode 100644 index 000000000000..a1fb13c1d3d1 --- /dev/null +++ b/stubs/geopandas/geopandas/tools/make_grid.pyi @@ -0,0 +1,17 @@ +from typing import Literal + +from shapely import MultiPolygon, Polygon + +from ..geodataframe import GeoDataFrame +from ..geoseries import GeoSeries + +def make_grid( + input_geometry: Polygon | MultiPolygon | GeoSeries | GeoDataFrame, + /, + cell_size: float, + grid_type: Literal["square", "hexagon"] = "square", + feature_type: Literal["centers", "corners", "polygons"] = "polygons", + offset: tuple[float, float] | None = None, + intersect: bool = True, + flat_topped: bool = False, +) -> GeoSeries: ...