# Calculate Distance to Nearest Pacific Boundary

> Combine all Pacific plate boundary geometries using `.unary_union` and calculate the distance from each earthquake to this combined boundary geometry. Returns the minimum distance in kilometers for each earthquake.

- Skill: `cxcscmu/calculate-distance-to-nearest-pacific-boundary` (Agent Skill)
- Install (CLI): `npx get-skill add cxcscmu/calculate-distance-to-nearest-pacific-boundary`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cxcscmu/calculate-distance-to-nearest-pacific-boundary/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: cxcscmu (https://skillmd.com/u/cxcscmu)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/cxcscmu/calculate-distance-to-nearest-pacific-boundary

---


```python
def calculate_distances_to_boundary(earthquakes_proj, boundaries_proj):
    """
    Calculate distance from each earthquake to the nearest Pacific boundary.
    
    Args:
        earthquakes_proj: GeoDataFrame with earthquakes in EPSG:4087
        boundaries_proj: GeoDataFrame with Pacific boundaries in EPSG:4087
        
    Returns:
        GeoDataFrame with added 'distance_km' column
    """
    # Combine all boundary geometries into single geometry
    combined_boundaries = boundaries_proj.geometry.unary_union
    
    # Calculate distance from each earthquake to combined boundary
    # EPSG:4087 uses meters, so divide by 1000 for kilometers
    earthquakes_proj['distance_km'] = earthquakes_proj.geometry.distance(
        combined_boundaries
    ) / 1000
    
    return earthquakes_proj
```
