Created
December 27, 2019 05:09
-
-
Save allenday/a92a9249a236e33c8186da925ef519d7 to your computer and use it in GitHub Desktop.
Find all OpenStreetMap changeset IDs that contain points in Singapore's geographical extent
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 singapore AS ( | |
SELECT ST_MAKEPOLYGON(ST_MAKELINE( | |
[ST_GEOGPOINT(103.6920359,1.1304753),ST_GEOGPOINT(104.0120359,1.1304753), | |
ST_GEOGPOINT(104.0120359,1.4504753),ST_GEOGPOINT(103.6920359,1.4504753) | |
] | |
)) AS boundingbox | |
) | |
SELECT DISTINCT changeset.id | |
FROM | |
`bigquery-public-data.geo_openstreetmap.history_changesets` AS changeset JOIN UNNEST(nodes) AS cnode, | |
`bigquery-public-data.geo_openstreetmap.history_nodes` AS nodes, | |
singapore | |
WHERE cnode = nodes.id | |
AND ST_INTERSECTS(singapore.boundingbox, nodes.geometry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment