Skip to content

Instantly share code, notes, and snippets.

@torgeir
Last active June 23, 2021 11:47
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 torgeir/d117ec66b7eaa8b4b83cac6eebf8ab1a to your computer and use it in GitHub Desktop.
Save torgeir/d117ec66b7eaa8b4b83cac6eebf8ab1a to your computer and use it in GitHub Desktop.
Geojson with properties, extracted from bigquery
[
{
"json": "{\"type\":\"MultiLineString\",\"coordinates\":\"[[[11.36588,61.13079], ... , [11.007229,61.572116]]]\",\"properties\":{\"description\":\"Stengt på grunn ... . \"}}"
},
...
{
"json": "{\"type\":\"LineString\",\"coordinates\":\"[[10.402729,62.429979], ... ,[10.335529,62.561779]]\",\"properties\":{\"description\":\"Stengt på grunn ... .\"}}"
}
]
SELECT
TO_JSON_STRING(t) as json
FROM
(SELECT
JSON_VALUE(geojson, "$.type") as type,
JSON_QUERY(geojson, "$.coordinates") as coordinates,
STRUCT(description) as properties
FROM
(SELECT
ST_ASGEOJSON(correctedGeography) geojson,
description
FROM `dataset.table`
LIMIT 10)) as t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment