[英]How to use ST_UNION in BigQuery
I have a table in BigQuery, called project.dataset.table
.我在 BigQuery 中有一个表,称为project.dataset.table
。 This table, among some other columns, has an ourpolygons
column, with datatype GEOGRAPHY
.除了其他一些列之外,该表还有一个ourpolygons
列,数据类型为GEOGRAPHY
。
I am trying to apply ST_UNION
to the ourpolygons
column, to get a multipolygon, a union of all our polygons.我正在尝试将ST_UNION
应用于我们的ourpolygons
列,以获得多多边形,即我们所有多边形的并集。 ST_UNION
is a Geography function in BigQuery . ST_UNION
是BigQuery 中的地理 function 。
Using this answer , I tried:使用这个答案,我试过:
SELECT ST_UNION(ourpolygons) FROM (SELECT ourpolygons FROM `project.dataset.table`) AS multipolig;
I get the error:我收到错误:
No matching signature for function ST_UNION for argument types: GEOGRAPHY. Supported signatures: ST_UNION(GEOGRAPHY, GEOGRAPHY); ST_UNION(ARRAY<GEOGRAPHY>) at [1:8]
I also tried:我也试过:
SELECT ST_UNION(ourpolygons) FROM `project.dataset.table` AS multipolig;
Giving me the error:给我错误:
No matching signature for function ST_UNION for argument types: GEOGRAPHY. Supported signatures: ST_UNION(GEOGRAPHY, GEOGRAPHY); ST_UNION(ARRAY<GEOGRAPHY>) at [1:8]
Eventually, I would put the result into a new table, with one row: the union.最后,我会将结果放入一个新表中,其中一行:并集。
How do I select all polygons from an existing table and create their union?我如何 select 来自现有表的所有多边形并创建它们的联合?
You should use ST_UNION_AGG
instead of ST_UNION
您应该使用ST_UNION_AGG
而不是ST_UNION
ST_UNION
is to make a union horizontally in your table: when you have a column with an array of geography object that you want to transform into a single one, or two columns of geography objects that you want to merge into two. ST_UNION
是在您的表中水平合并:当您有一个包含地理数组 object 的列时,您想要将其转换为一个或两个要合并为两个地理对象的列。 At the end of the operation, your table has the same number of rows.在操作结束时,您的表具有相同的行数。
ST_UNION_AGG
is to make a union vertically : you have one column of geography objects that you want to aggregate into a single one (perhaps per group..) At the end of the operation, your rows have been aggregated into only one row (or the number of groups, if you have a GROUP BY
) ST_UNION_AGG
是垂直合并:你有一列地理对象,你想聚合成一个单一的(也许每组......)在操作结束时,你的行已经聚合成只有一行(或组数,如果你有GROUP BY
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.