A land-use commission is comparing states by their built-up share, using the Natural Earth urban-area footprints as a first pass before the expensive satellite product arrives. The commission's own summary summed each footprint's `area_sqkm` into the state that contained its centroid, which put all of the New York metro into New Jersey. You are asked to do it properly: clip every footprint to the state line and measure what actually lies on each side.
Write a script that produces a per-state urban-footprint table.
The datasets are mounted where the script runs:
/data/states.geojson — the 50 states and DC/data/urban.geojson — 2,143 urban-area footprints worldwidegeopandas, 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 stateurban_km2 — area of urban footprint inside the state, km²urban_pct — that as a percentage of the state's areaArea is measured in an equal-area projection — EPSG:5070 (NAD83 / Conus Albers) is the standard one for the United States and stays equal-area for Alaska and Hawaii, if not pretty. A footprint that straddles a state line contributes to both states, each its own part; area_sqkm on the footprint is the whole polygon and is not to be used. 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/urban.geojson — EPSG:4326; the geometry is in geometry (Polygon).
| column | type | meaning |
|---|---|---|
urban_id | string | Footprint identifier, UA- and four digits |
area_sqkm | number | Natural Earth's own area of the whole footprint (km²) |
scalerank | integer | Prominence, lower is larger |
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.
Clip-and-credit overlays are how land cover, flood extent and any other footprint layer is attributed to the administrative units that report on it.
Files: /data/states.geojson, /data/urban.geojson · assign result
5 scored, 0 informational
Clips footprints to states with an overlay
17%One row per state
17%Carries postal, urban_km2 and urban_pct
17%Total urban footprint inside the states
33%The most built-up unit's share
17%