| name | spatial-distance-to-boundary |
| description | Calculate the shortest distance between points (earthquakes) and a complex line geometry (plate boundaries). |
To find the distance from points to a boundary:
- Isolate the boundary geometry. This can be the boundary of a plate polygon (
plate_gdf.geometry.boundary) or a separate LineString dataset.
- If the boundary consists of multiple segments, use
.union_all() (in GeoPandas 1.0+) or .unary_union to create a single geometry object for comparison.
- Use the
.distance() method on the points GeoDataFrame against the unified boundary geometry.
- To find the point furthest from the boundary, use
.loc[gdf['distance_col'].idxmax()].
boundary_geom = boundaries_gdf.union_all()
gdf['dist_to_boundary'] = gdf.geometry.distance(boundary_geom)
furthest_record = gdf.loc[gdf['dist_to_boundary'].idxmax()]