1

I'm trying to convert some Very Big Shapefiles into GeoJSON so that I can run them through tippecanoe and create a .mbtiles to upload to Mapbox Studio for hosting and styling.

I can use ogr2ogr to create my GeoJSON file just fine, however it outputs a FeatureCollection with nice formatting. What I want is a .json file with one feature per line, so that I can use the 'Parallel processing of input' feature of Tippecanoe and speed up creation of my .mbtiles.

Question 1: Is there a way to do this simply with ogr2ogr? I can't seem to find a relevant option in the GDAL GeoJSON driver docs.

Question 2: Alternatively, could ogr2ogr output a GeoJSON text sequence instead of a FeatureCollection file?

Community
  • 1
  • 1
craig
  • 285
  • 2
  • 10

3 Answers3

0

If you make an array of the ids or any other attribute in your Shapefile, you could loop through this list and use the ogr2ogr --where option to export features one by one. See also this example https://gis.stackexchange.com/questions/35296/how-to-use-where-sql-in-an-ogr2ogr-loop-in-gdal-ogr-bash#35297

0

Q1. Well, you can extract the individual features with the help of a UNIX tool - jq.

    jq --compact-output ".features" input_featurecollection.geojson > output_features_only.geojson

This will have each record as a separate geojson feature

Q2 you can pipe in your input geojson file to this command and echo the output.

Shree
  • 533
  • 1
  • 5
  • 10
0

You can use ogr2ogr to output a geojson sequence as you suggested in question 2 @craigsnyders:

ogr2ogr -f GeoJSONSeq -t_srs EPSG:4326 output.json input.shp