Created
June 28, 2021 14:45
-
-
Save mbforr/599fffaf4ca0b69cd8a812b46472ddaa to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
buildings AS ( | |
SELECT | |
id, | |
latitude, | |
longitude, | |
username, | |
osm_timestamp, | |
FROM | |
`bigquery-public-data.geo_openstreetmap.planet_nodes` | |
WHERE | |
'building' IN ( | |
SELECT | |
key | |
FROM | |
UNNEST(all_tags)) ) | |
SELECT | |
COUNT(b.id), | |
a.geoid | |
FROM | |
`carto-do-public-data.carto.geography_usa_blockgroup_2019` a | |
JOIN | |
buildings b | |
ON | |
st_intersects(st_geogpoint(b.longitude, | |
b.latitude), | |
a.geom) | |
GROUP BY | |
a.geoid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment