Contains/Covers/Intersects/Within?

SELECT * FROM countries c, points p 
WHERE st_contains(c.geog, p.geog)
  • When b is a point, it returns FALSE for points exactly at the border. Note that exactly means within snapping distance, used to make predicates consistent, which for BigQuery GIS is ~ 1 micron.
  • When b is a polygon, ST_Contains is identical to ST_Covers (exercise for the reader is to check this follows from definition above). Note polygon b might have points at the a boundary, but if no points are outside — ST_Contains return TRUE.
Six arrangements of points and polygons demonstrating results of ST_* functions.
  1. ST_Intersects = true, ST_Covers = true, ST_Contains = true.
  2. ST_Intersects = true, ST_Covers = true, ST_Contains = true.
  3. ST_Intersects = true, ST_Covers = true, ST_Contains = false.
  4. ST_Intersects = true, ST_Covers = true, ST_Contains = true.
  5. ST_Intersects = false, ST_Covers = false, ST_Contains = false.
  6. ST_Intersects = true, ST_Covers = false, ST_Contains = false.

--

--

Hi, I'm TL of BigQuery Geospatial project. Posting small recipes and various notes for BQ Geospatial users.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Entin

Michael Entin

151 Followers

Hi, I'm TL of BigQuery Geospatial project. Posting small recipes and various notes for BQ Geospatial users.