import geopandas as gpd
gdf = gpd.read_file("data/municipalities.gpkg")
gdf.head()16 GeoPandas
16.1 Read a spatial file
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
mergefor attribute keys andsjoinfor spatial relationships. - Check the CRS before spatial operations.