我在BigQuery中使用BNG系统加载了Easting,Northing点。
通常我将它们读入r然后转换(从CRS(“+ init = epsg:27700”)到CRS(“+ init = epsg:4326”))。
是否有可能实际使用UDF在BigQuery中执行此操作?
这里有JS代码:http://www.movable-type.co.uk/scripts/latlong-os-gridref.html进行转换。
我如何实际将其转换为UDF,特别是能够在bigrquery中使用UDF?
谢谢!
答案 0 :(得分:0)
要在UDF中使用此JavaScript代码,您可以:
CREATE TEMP FUNCTION
来定义UDF。使用OPTIONS
子句并指定要加载的library
paths。最终查询看起来像这样:
CREATE TEMP FUNCTION ConvertCoordinate(input STRING)
RETURNS STRING
LANGUAGE js AS
"""
// Assumes 'jsConvertCoordinate' is defined in one of the library files.
return jsConvertCoordinate(input);
"""
OPTIONS (
library="gs://my-bucket/path/to/lib1.js",
library="gs://my-bucket/path/to/lib2.js"
);
SELECT ConvertCoordinate(coordinate) AS converted_coordinate
FROM MyTable;