Skip to content

Instantly share code, notes, and snippets.

@mbforr
Created July 6, 2021 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbforr/cbaca493116ceea0fe7152bfa18b6bb1 to your computer and use it in GitHub Desktop.
Save mbforr/cbaca493116ceea0fe7152bfa18b6bb1 to your computer and use it in GitHub Desktop.
select
# this will create a new column using a function
# this won't be a part of the dataset, just the query itself
# we can calculate the area of the geometry in sq. meters
# then transform that using math to sq. miles
# we can also use a column alias here - as square_miles
# you can call this column anything you want, just change "square_miles"
st_area(state_geom) / 2.59e+6 as square_miles
from
`bigquery-public-data.geo_us_boundaries.states`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment