types-geopandas

raw JSON →
1.1.3.20260408 verified Mon Apr 27 auth: no python

PEP 561 typing stubs for geopandas, provided by typeshed. Version 1.1.3.20260408 supports Python >=3.10. These stubs allow static type checkers like mypy and pyright to understand geopandas types. They are released on a rolling schedule, synced to geopandas releases.

pip install types-geopandas
error ModuleNotFoundError: No module named 'geopandas'
cause Installation of types-geopandas only installs stubs, not geopandas itself.
fix
Run: pip install geopandas
error error: Name 'GeoDataFrame' is not defined
cause User imported from an internal module instead of top-level geopandas.
fix
Use: from geopandas import GeoDataFrame
gotcha types-geopandas is not the same as geopandas itself. You must install geopandas separately (pip install geopandas). Many users mistakenly think installing types-geopandas provides geopandas functionality.
fix Ensure both are installed: pip install geopandas types-geopandas
deprecated Older versions of geopandas used shapely.geometry types directly. In geopandas >=0.12, they moved to using shapely 2.0 Geometry types. The stubs reflect this, so code expecting old type names may break.
fix Use shapely.geometry.Point (or other) as the underlying geometry type. For example: from shapely.geometry import Point
gotcha The stubs are auto-generated and may lag behind geopandas releases. If you encounter type errors that seem incorrect, check if a newer types-geopandas version is available. If not, you may need to add inline # type: ignore comments.
fix Upgrade: pip install --upgrade types-geopandas

Basic usage: import geopandas, use read_file to get a GeoDataFrame with type hints.

import geopandas as gpd

# Ensure stubs are installed (types-geopandas) so mypy can check
# Example: create a GeoDataFrame from a file
# Replace 'filepath' with a real path or use built-in example
# df: gpd.GeoDataFrame = gpd.read_file('filepath')

# Example with world dataset (requires geopandas.datasets)
df = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
print(type(df))  # mypy will infer GeoDataFrame thanks to stubs