Run3 load and inspect geodata
Load GeoJSON files with GeoPandas and inspect their structure — columns, CRS, geometry types, and sample rows. Use this before any spatial analysis to understand field names and data layout.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill run3_load-and-inspect-geodataAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
2.2 KB, 547 tokens by cl100k_base, as published. Nobody here has run it
Loading and Inspecting GeoDataFrames
import geopandas as gpd
import json
def inspect_geodataframe(path, label="GeoDataFrame", n=3):
gdf = gpd.read_file(path)
print(f"\n=== {label} ===")
print(f"CRS: {gdf.crs}")
print(f"Shape: {gdf.shape}")
print(f"Columns: {list(gdf.columns)}")
print(f"Geometry types: {gdf.geom_type.value_counts().to_dict()}")
print(f"\nSample rows:")
print(gdf.head(n).to_string())
return gdf
# Usage:
# plates = inspect_geodataframe("/root/PB2002_plates.json", "Plates")
# boundaries = inspect_geodataframe("/root/PB2002_boundaries.json", "Boundaries")
# earthquakes_raw = json.load(open("/root/earthquakes_2024.json"))
Loading Earthquake JSON
import json
import geopandas as gpd
from shapely.geometry import Point
def load_earthquakes(path):
with open(path) as f:
data = json.load(f)
features = data["features"]
rows = []
for feat in features:
props = feat["properties"]
coords = feat["geometry"]["coordinates"]
rows.append({
"id": feat["id"],
"place": props.get("place"),
"time_ms": props.get("time"),
"magnitude": props.get("mag"),
"longitude": coords[0],
"latitude": coords[1],
"geometry": Point(coords[0], coords[1])
})
import pandas as pd
gdf = gpd.GeoDataFrame(rows, geometry="geometry", crs="EPSG:4326")
# Convert time from ms to ISO 8601
gdf["time"] = pd.to_datetime(gdf["time_ms"], unit="ms", utc=True).dt.strftime("%Y-%m-%dT%H:%M:%SZ")
return gdf
# earthquakes = load_earthquakes("/root/earthquakes_2024.json")
# print(earthquakes.head())
Key notes:
- Always print
.columnsbefore accessing fields — plate files often use"Code"not"name"or"Name". - Check for
PlateA/PlateBin the boundaries file before filtering. - Earthquake time is in milliseconds since epoch — convert with
pd.to_datetime(..., unit="ms", utc=True).
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.