plate-tectonics-geospatial
Analyze plate tectonics data using GeoPandas, identify points within plates, and calculate distances to boundaries.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 92
- Forks
- 7
01 前言 Front Matter
- name
- plate-tectonics-geospatial
- description
- Analyze plate tectonics data using GeoPandas, identify points within plates, and calculate distances to boundaries.
03 SKILL.md 正文
Plate Tectonics Geospatial Analysis
Overview
The PB2002 (Plate Boundaries 2002) dataset provides comprehensive data on tectonic plate boundaries and plate definitions. This skill covers loading, processing, and spatial analysis of plate data.
PB2002 Dataset Structure
Boundary Data (PB2002_boundaries.json)
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [[lon1, lat1], [lon2, lat2], ...]
},
"properties": {
"PLATE1": "Pacific",
"PLATE2": "North American",
"TYPE": "subduction zone", // or "transform", "spreading", etc.
"STEPOVER": ""
}
}
]
}
Plate Data (PB2002_plates.json)
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon", // or Polygon
"coordinates": [...]
},
"properties": {
"PlateName": "Pacific",
"PlateID": 101
}
}
]
}
Loading and Processing
Load Plate Boundaries
import geopandas as gpd
import json
with open('/root/PB2002_boundaries.json', 'r') as f:
boundaries_geojson = json.load(f)
boundaries_gdf = gpd.GeoDataFrame.from_features(
boundaries_geojson['features'],
crs='EPSG:4326'
)
# Filter for specific plate boundary
pacific_boundaries = boundaries_gdf[
(boundaries_gdf['PLATE1'] == 'Pacific') |
(boundaries_gdf['PLATE2'] == 'Pacific')
]
Load Plate Polygons
with open('/root/PB2002_plates.json', 'r') as f:
plates_geojson = json.load(f)
plates_gdf = gpd.GeoDataFrame.from_features(
plates_geojson['features'],
crs='EPSG:4326'
)
# Get Pacific plate polygon
pacific_plate = plates_gdf[plates_gdf['PlateName'] == 'Pacific']
Spatial Operations
Identify Points Within Plate
# Use spatial join to find earthquakes within Pacific plate
earthquakes_in_pacific = gpd.sjoin(
earthquakes_gdf,
pacific_plate,
how='inner',
predicate='within'
)
Calculate Distance to Boundary
# For each earthquake, calculate minimum distance to boundary
def min_distance_to_boundary(point, boundary_lines_gdf):
"""Calculate minimum distance from point to any boundary line"""
min_dist = float('inf')
for idx, boundary in boundary_lines_gdf.iterrows():
dist = point.distance(boundary['geometry'])
if dist < min_dist:
min_dist = dist
return min_dist
# Apply to all earthquakes in the plate
# First, project to projected CRS for accurate distance in km
earthquakes_projected = earthquakes_in_pacific.to_crs('EPSG:3857')
boundaries_projected = pacific_boundaries.to_crs('EPSG:3857')
earthquakes_projected['distance_to_boundary'] = earthquakes_projected.geometry.apply(
lambda point: min_distance_to_boundary(point, boundaries_projected)
)
# Convert from meters to kilometers
earthquakes_projected['distance_km'] = earthquakes_projected['distance_to_boundary'] / 1000
Find Maximum Distance
# Find earthquake furthest from boundary
furthest_idx = earthquakes_projected['distance_km'].idxmax()
furthest_earthquake = earthquakes_projected.loc[furthest_idx]
Important Considerations
Polygon Validation
# Ensure polygons are valid before spatial operations
if not plates_gdf.geometry.is_valid.all():
plates_gdf['geometry'] = plates_gdf.geometry.buffer(0)
if not boundaries_gdf.geometry.is_valid.all():
boundaries_gdf['geometry'] = boundaries_gdf.geometry.buffer(0)
Handling MultiPolygons
# If a plate is represented as MultiPolygon, create a union
pacific_plate_union = pacific_plate.unary_union
Projection for Accurate Distances
# Use Web Mercator (EPSG:3857) for global distances in meters
# Then convert to kilometers
# For regional analysis, consider UTM zones
# EPSG:32633 = UTM Zone 33N
# EPSG:32733 = UTM Zone 33S
Common Pitfalls
- Not projecting before distance calculations - Distances in geographic CRS are meaningless
- Invalid geometries - Use
.buffer(0)to fix self-intersecting polygons - Antimeridian issues - Points near ±180° longitude may have wrapping issues
- MultiPolygon confusion - Remember that a plate may consist of multiple disconnected polygons
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.