[英]How to filter on geography data in BigQuery
I am in need to filter my BigQuery table based on column which is of type Geography.我需要根据地理类型的列过滤我的 BigQuery 表。 I tried below queries SELECT * FROM bigqueryproject1-279667.mycreatedataset1.newTabelwithAllDatatype where location = ST_GEOGPOINT(-6, 6)
but this shows me validation error Equality is not defined for arguments of type GEOGRAPHY.我尝试了以下查询SELECT * FROM bigqueryproject1-279667.mycreatedataset1.newTabelwithAllDatatype where location = ST_GEOGPOINT(-6, 6)
但这显示验证错误 Equality is not defined for arguments of type GEOGRAPHY。 If I replcae '=' with like operator I get message stating like is applicable only for String and Byte.如果我用 like 运算符替换 '=',我会收到消息,说明 like 仅适用于字符串和字节。 I refereed this documentation but not getting how to have filter.我参考了此文档,但没有了解如何使用过滤器。
I think you want something like this:我想你想要这样的东西:
WHERE ST_INTERSECTS(location, ST_GEOGPOINT(-6, 6))
For geography, equality operator is not defined.对于地理,未定义相等运算符。
You can use ST_Equals
, like ST_Equals(location, ST_GEOGPOINT(-6, 6))
if you really want only rows with geography value (almost) exactly equal to this point.您可以使用ST_Equals
,如ST_Equals(location, ST_GEOGPOINT(-6, 6))
如果您真的只想要地理值(几乎)完全等于这一点的行。
More often you would want to filter on other conditions, eg intersections with specific point, use ST_Intersects(location, ST_GEOGPOINT(-6, 6))
or on condition of being within some distance of a point, use ST_DWithin(location, ST_GEOGPOINT(-6, 6), 100)
where last argument is distance in meters.更常见的情况是,您希望根据其他条件进行过滤,例如与特定点的交点,使用ST_Intersects(location, ST_GEOGPOINT(-6, 6))
或在点的一定距离内的条件下,使用ST_DWithin(location, ST_GEOGPOINT(-6, 6), 100)
其中最后一个参数是以米为单位的距离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.