Skip to content
Advertisement

Extract n coordinates from Line – Bigquery

I want to extract n coordinates (latitude, longitude) from a geography object (a line) I have on big query.

Is there a way to specify how many st_geogpoint I want to obtain? (which can be more or less than the st_geogpoint used to create the line with st_makeline)

Example:

I want to be able to extract n (where n>=2) st_geogpoint from that line. Is it possible?

Output expected if n=2

Output expected if n=10

I can’t give the example of points in between the first and last, because I’m expecting them to be extracted from the LINE according to the value of n

Advertisement

Answer

Below is for BigQuery Standard SQL

You can test, play with above using sample data from your question as in below example

with result

obviously by adjusting 1 and 3 in below line you ncan control the number of points to output

In case when you expect output in same row as an array – see below

this one produces array

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement