Created
August 11, 2021 02:31
-
-
Save mbforr/bf93b08dc4b9e2a601b8c82da9e03386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
b AS ( | |
SELECT | |
st_union_agg(road_geom) AS road_geom, | |
full_name | |
FROM | |
`bigquery-public-data.geo_us_roads.us_national_roads` | |
GROUP BY | |
full_name ) | |
SELECT | |
COUNT(b.full_name) AS interstates, | |
a.state_name, | |
ARRAY_AGG(b.full_name) AS roads | |
FROM | |
`bigquery-public-data.geo_us_boundaries.states` a | |
JOIN | |
b | |
ON | |
st_contains(a.state_geom, | |
b.road_geom) | |
WHERE | |
b.full_name LIKE 'I-%' | |
AND st_LENGTH(b.road_geom) > 5000 | |
GROUP BY | |
a.state_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment