16  GeoPandas

16.1 Read a spatial file

import geopandas as gpd

gdf = gpd.read_file("data/municipalities.gpkg")
gdf.head()

16.2 Inspect the CRS and geometry

print(gdf.crs)
print(gdf.geometry.geom_type.value_counts())

16.3 Reproject

projected = gdf.to_crs("EPSG:6372")

16.4 Attribute join

joined = gdf.merge(attributes, on="cve_geo", how="left")

16.5 Things to remember

  • A GeoDataFrame has one active geometry column.
  • Use merge for attribute keys and sjoin for spatial relationships.
  • Check the CRS before spatial operations.