Run1 geopandas spatial filtering
Use GeoPandas to filter points within a specific polygon, such as finding earthquakes within a specific tectonic plate.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill run1_geopandas-spatial-filteringAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.0 KB, 206 tokens by cl100k_base, as published. Nobody here has run it
To filter points based on their location within a polygon:
- Load the polygon data (e.g., plate geometries) and the point data (e.g., earthquakes) into GeoDataFrames.
- Ensure both GeoDataFrames use the same Coordinate Reference System (CRS), typically WGS84 (EPSG:4326).
- Identify the target polygon (e.g., the Pacific Plate, often abbreviated as 'PA' in PB2002 datasets).
- Use the
.within()predicate or a spatial joingpd.sjoin()to filter the points.
import geopandas as gpd
# Load datasets
plates = gpd.read_file('plates.json')
points = gpd.read_file('points.json')
# Extract specific plate (e.g., Pacific Plate 'PA')
pacific_plate = plates[plates['Code'] == 'PA'].geometry.iloc[0]
# Filter points within the polygon
points_in_plate = points[points.within(pacific_plate)]
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.