Skip to content

Instantly share code, notes, and snippets.

@wriglz
Created December 16, 2022 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wriglz/18330f3f7857e8ba157cd8126985973b to your computer and use it in GitHub Desktop.
Save wriglz/18330f3f7857e8ba157cd8126985973b to your computer and use it in GitHub Desktop.
Function to create a UDF to replicate ST_LineLocatePoint on Google BigQuery
CREATE OR REPLACE FUNCTION
demo.ST_LineLocatePoint(line GEOGRAPHY,
point GEOGRAPHY)
RETURNS FLOAT64 AS (ST_DISTANCE(ST_STARTPOINT(line),ST_CLOSESTPOINT(line, point) )/ST_LENGTH(line) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment