Skip to content

Instantly share code, notes, and snippets.

@mbforr
Created July 6, 2021 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbforr/dd9d8df1f91a9934a78f313b57fa4770 to your computer and use it in GitHub Desktop.
Save mbforr/dd9d8df1f91a9934a78f313b57fa4770 to your computer and use it in GitHub Desktop.
select
state_name, state
from
`bigquery-public-data.geo_us_boundaries.states`
# our first spatial sql function - st_area
# this function takes the geometry and returns the area in sq. meters
# we will look for states where the area is greater or equal to 200k sq. km (2e+11)
# we can also use different operators in our where clause
# https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_area
# https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
where st_area(state_geom) >= 2e+11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment