如何获取包含在另一个多边形中的多边形,包括那些触及 BigQuery Standard SQL 边界的多边形?

How to get polygons contained within another polygon, including those that touch the border in BigQuery Standard SQL?

我正在尝试获取包含在 BigQuery 中指定市场区域多边形内的块组。我试过使用 st_containsst_covers 但我仍然只得到完全包含的(而不是边界的:

SELECT a.blockgroup_geom as the_geom,
a.geo_id,
c.total_pop 

FROM `bigquery-public-data.geo_census_blockgroups.us_blockgroups_national` a

join `bigquery-public-data.census_bureau_acs.blockgroup_2018_5yr` c
 
on a.geo_id = c.geo_id

join `bigquery-public-data.geo_us_boundaries.designated_market_area` b
on st_covers(b.dma_geom,a.blockgroup_geom)
where b.dma_name = 'Milwaukee, WI'

我需要做什么才能获得 dma 多边形内的所有块组?

看起来这两个数据集没有完全对齐,因此两个多边形之间的任何细微差异,或者由于平面到球面转换而导致的错误都会阻止多边形的完美嵌套。

这个 post 有更深入的讨论以及如何处理这个问题的想法:https://mentin.medium.com/creating-spatial-hierarchy-2ba5488eac0a

这里我会尝试 ST_Intersects 条件并检查交集区域以查看块组的大部分是否属于 DMA:

SELECT a.blockgroup_geom as the_geom,
  a.geo_id,
  c.total_pop,
  (st_area(st_intersection(b.dma_geom,a.blockgroup_geom))
       > 0.75 * st_area(a.blockgroup_geom)) as mostly

FROM `bigquery-public-data.geo_census_blockgroups.us_blockgroups_national` a
join `bigquery-public-data.census_bureau_acs.blockgroup_2018_5yr` c
on a.geo_id = c.geo_id
join `bigquery-public-data.geo_us_boundaries.designated_market_area` b
on st_intersects(b.dma_geom,a.blockgroup_geom)
where b.dma_name = 'Milwaukee, WI'

这个结果有意义吗?我用 mostly = true 给绿色多边形上色,用 mostly = false 给蓝色多边形上色: