Geopandas projections
Using GeoPandas coordinate projections for accurate distance calculations on geospatial data.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill geopandas-projectionsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.9 KB, 477 tokens by cl100k_base, as published. Nobody here has run it
GeoPandas Projections for Distance Calculations
Overview
When calculating distances between geographic features, you must project from geographic coordinates (lat/lon, EPSG:4326) to a projected CRS that preserves distances. Using .distance() on unprojected data gives degrees, not meters/km.
Key Projections
World Azimuthal Equidistant (ESRI:54032)
- Preserves distances from center point
- Good for measuring distances from a single point to boundaries
- Usage:
gdf.to_crs("ESRI:54032")
Equal Area Cylindrical (EPSG:6933)
- Preserves area, approximate distances
- Usage:
gdf.to_crs("EPSG:6933")
Custom Azimuthal Equidistant
- Best accuracy when measuring from a known center point
proj_str = f"+proj=aeqd +lat_0={lat} +lon_0={lon} +datum=WGS84 +units=m"
Distance Calculation Pattern
import geopandas as gpd
from shapely.ops import nearest_points
# Load data in WGS84
gdf = gpd.read_file("data.geojson") # EPSG:4326
# Project to meters-based CRS
gdf_proj = gdf.to_crs("ESRI:54032")
# Calculate distance (returns meters)
dist = gdf_proj.geometry.distance(some_geometry_proj)
# Convert to km
dist_km = dist / 1000
Handling the Antimeridian (Date Line)
The Pacific plate crosses the antimeridian (±180° longitude). Standard projections may split geometries. Solutions:
- Use a Pacific-centered projection with
+lon_0=180or+lon_0=-160 - Shift longitudes to 0-360 range before projecting
- Use azimuthal equidistant centered on Pacific
Point-to-LineString Distance
from shapely.ops import nearest_points
# For a point to a boundary (MultiLineString)
point_proj = earthquake_point.to_crs(proj_crs)
boundary_proj = boundary.to_crs(proj_crs)
distance = point_proj.geometry.distance(boundary_proj.unary_union)
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.