【发布时间】:2022-01-22 07:25:50
【问题描述】:
我正在尝试创建一个使用 Googles Geocoding service 的 Bigquery UDF 函数。
看来我们可以使用option parameter 导入外部库,但我觉得我不能在这里使用地理编码服务。
按照我的函数方法:
CREATE OR REPLACE FUNCTION
functions.returnGeoCode(address STRING)
RETURNS Array<String>
LANGUAGE js AS """
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude);
}
});
"""
抱怨是因为当我尝试使用该功能时它不知道google 当然会说ReferenceError: google is not defined at UDF$1(STRING) line 2, columns 23-24。
我的最终目标是将我在 Bigquery 数据集中的地址转换为纬度/经度,这样我就可以在可视化工具中创建热图。
对我的方法或完全不同的方法有什么建议吗?我看到了一些使用一些公共 Bigquery 数据集 (openstreetmaps suggestion) 的建议,但我有来自德国的地址,但它并没有很好地涵盖。
Bigquery 似乎也不支持the conversion this way。
提前谢谢你!
【问题讨论】:
标签: google-bigquery geocoding reverse-geocoding google-geocoding-api bigquery-udf