GeoPandas Projections for Distance Calculations
SkillDev toolsUsing GeoPandas coordinate projections for accurate distance calculations on geospatial data.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the GeoPandas Projections for Distance Calculations skill
What this skill tells your AI
The instructions your AI receives, as published by cxcscmu/skilllearnbench in skills/b1-one-shot-claude-opus-4-6/earthquake-plate-calculation/geopandas-projections/SKILL.md and read by ahel’s review.
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)
Signals
- GitHub stars
- 83
- Forks
- 5
- Last commit
- Jul 2026
Advanced
- Catalog kind
- skill
- Gateway key
geopandas-projections- Source
- github.com/cxcscmu/skilllearnbench