I'm loving the ndjson-cli tools for working with newline-delimited GeoJSON files. But I can't seem to find a tool that converts a standard GeoJSON (whether minified or prettified) ond converts it to newline-delimited. Is there one?
cat my.geojson | jq -c ".features" > nld_features.json
The important parts here are the
-c flag which prints compact JSON objects on a single line, and the filter
".features" which selects the features object from the top level of the object, and then calls an Array/Object iterator over the values to break the features into separate JSON objects.
If you want to extract coordinates as well, you can use the different filters in jq to extract the values as well.
I wrote a dedicated command-line tool on NPM to do this, now:
npm install -g geojson2ndjson
geojson2ndjson myfile.geojson | ...
Or read from standard input:
cat myfile.geojson | geojson2ndjson | ...
List the properties of every feature, without the geometries:
geojson2ndjson myfile.geojson | ndjson-map d.properties