Skip to content

Instantly share code, notes, and snippets.

@wriglz
Created October 3, 2022 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wriglz/39143445316ff9c33fe4716145b163b7 to your computer and use it in GitHub Desktop.
Save wriglz/39143445316ff9c33fe4716145b163b7 to your computer and use it in GitHub Desktop.
SQL to query OSM data on Google BigQuery
SELECT
osm_id,
feature_type,
osm_timestamp,
geometry,
-- Here we are going to extract a couple of attributes from the all_tags array:
(SELECT value FROM UNNEST(all_tags) WHERE key = 'name' ) AS name,
(SELECT value FROM UNNEST(all_tags) WHERE key = 'addr:city') AS city
FROM
bigquery-public-data.geo_openstreetmap.planet_features
WHERE
('amenity', 'pub') IN ( -- the Key Value pair that you want to search for.
SELECT
(key, value)
FROM
UNNEST(all_tags))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment