[GIS] How to reduce the file size of GeoJSON data

geojsonogr2ogrtigertopojson

For my project I am trying to convert the tiger shapefile information for us states into GeoJSON format

However when I use the ogr2ogr tool the data file is about 20 MB. I have seen the geoJSON file of US States elsewhere of around 88KB.

How do I reduce the output to geoJSON file?

Best Answer

You have two ways of reducing the file size:

  1. Remove all the pretty formatting and redundant white space. In some 'XML-style' files this can be a surprisingly large amount and can easily double or even treble your file size. However I doubt it accounts for the difference in your volume and the data you link to above.
  2. Reduce the volume of actual data either by reducing your coordinate precision (e.g. 6 decimal places vs say 12) and/or reducing the actual number of vertices representing the features in your data. I suspect that this accounts for a substantial proportion of the difference in file sizes you are seeing. Much depends on your use-case for how much simplification will be acceptable and only you can decide that.