A federal infrastructure office publishes an annual table of airports per state from a global registry, and last year's was produced by hand in a desktop tool. The analyst has left. This year the office wants a script: the registry drops in, the same code runs, the same table comes out — including the states with nothing to count, which the desktop version quietly omitted.
Write a script that produces a per-state airport table.
The datasets are mounted where the script runs:
/data/states.geojson — the 50 states and DC/data/airports.geojson — 893 airports worldwide; only some are in a stategeopandas, shapely, pyproj, pandas and numpy are available. Assign the finished table to a variable named `result`: a GeoDataFrame with one row per state, carrying the state polygon and
postal — the stateairports — airports inside the state, all typesmajor_airports — those whose type contains majorAssign airports to states by geometry. Airports outside every state — most of the file — are simply not counted. Do not write a file — the runner reads result.
/data/states.geojson — EPSG:4326; the geometry is in geometry (Polygon / MultiPolygon).
| column | type | meaning |
|---|---|---|
state_id | string | Natural Earth adm1 code |
name | string | State name |
postal | string | Two-letter postal abbreviation |
region | string | Census region: Northeast | Midwest | South | West |
type | string | State | Federal District |
/data/airports.geojson — EPSG:4326; the geometry is in geometry (Point).
| column | type | meaning |
|---|---|---|
airport_id | string | AP- plus the Natural Earth id |
name | string | Airport name |
iata_code | string | Three-letter IATA code; null for a few |
gps_code | string | Four-letter ICAO code |
type | string | major | mid | small | military | spaceport, and combinations such as 'major and military' |
location | string | What the point marks: terminal | ramp | runway | parking | freight | approximate |
scalerank | integer | Natural Earth prominence, 2 (largest) to 9 |
Run executes the script in your browser and shows you its output and a preview. Submit executes it again on the server and grades what result holds.
These are where the teaching is. Read them twice.
Points-in-polygons per administrative unit is the backbone of every national statistics table built from a facility registry, and scripting it is what lets the table be trusted next year.
Files: /data/states.geojson, /data/airports.geojson · assign result
5 scored, 0 informational
Assigns airports to states with a spatial predicate
18%One row per state
18%Carries postal, airports and major_airports
18%Total airports inside the states
27%Total major airports inside the states
18%