Importing GeoJSON with a deeply nested object array
· 5 min read
“Importing GeoJSON with a deeply nested object array“
Question
How do I import GeoJSON with a nested object array?
Answer
For this tutorial, we will use open data publicly available here. A copy can be found here.
-
Download the data in GeoJSON format and rename the file to
geojson.json
. -
Understand the structure.
DESCRIBE TABLE file('geojson.json', 'JSON')
┌─name─────┬─type─────────────────────────────────────────────────────────────────────────────────────────┐
│ type │ Nullable(String) │
│ name │ Nullable(String) │
│ crs │ Tuple( properties Tuple(name Nullable(String)),type Nullable(String)) │
│ features │ Array(Tuple( │
│ │ geometry Tuple(coordinates Array(Array(Array(Array(Nullable(Float64))))), │
│ │ type Nullable(String)), │
│ │ properties Tuple( CODIGOINE Nullable(String), │
│ │ CODNUT1 Nullable(String), │
│ │ CODNUT2 Nullable(String), │
│ │ CODNUT3 Nullable(String), │
│ │ FID Nullable(Int64), │
│ │ INSPIREID Nullable(String), │
│ │ NAMEUNIT Nullable(String), │
│ │ NATCODE Nullable(String), │
│ │ SHAPE_Area Nullable(Float64), │
│ │ SHAPE_Length Nullable(Float64) │
│ │ ), │
│ │ type Nullable(String) │