Yet another GeoJson to Ndjson converter

jq --compact-output '.features[] | (.geometry | tojson) as $g | . = .properties | .geometry |= $g' < input_file > output_file
  • .features[] selects individual feature in top level feature collection
  • .geometry | tojson saves the geometry field as quoted string to variable $g
  • we then create object based on feature’s .properties
  • and finally update this object’s .geometry field with saved variable $g.
  • — compact-output makes jq output every feature on its own line, which is exactly what BigQuery needs.
  • this only supports GeoJson with default coordinate reference system (other CRS were deprecated by standard, but are still used sometimes)
  • this only supports GeoJson that contains FeatureCollection object, would not work if file has a single top level Feature.

--

--

--

Hi, I'm TL of BigQuery Geospatial project. Posting small recipes and various notes for BQ Geospatial users.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Entin

Michael Entin

Hi, I'm TL of BigQuery Geospatial project. Posting small recipes and various notes for BQ Geospatial users.

More from Medium

Physical Modeling of Tables in BigQuery

Good News about the BigQuery Data Transfer Service

Google Analytics and BigQuery: setting up your project

Nested Record Processing with BigQuery