Michael Entin
Feb 3, 2021

--

Thank you, I should check the SQL syntax better.

Yes, it should be `ON`, not `WHERE`.

The JOIN syntax here should be either `... FROM a JOIN b ON ...`, or `FROM a, b WHERE ...`. Both work here and result in same query plan, I just should not have mixed the two together.

The solution should work for any type of geographies - ST_DWithin works with all of them, and uses the distance between the two nearest points of two inputs.

For some use cases, you might want to replace polygons with their centroids - e.g. if you care more about distance to city center, than distance to city boundary.

--

--

Michael Entin
Michael Entin

Written by Michael Entin

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

Responses (1)