CLI for converting TopoJSON files to GeoJSON
pip install topo2geo
$ topo2geo input.topojson output.geojson
If the topojson contains mulitple layers (i.e. there are multiple values in the "objects" key). Then seperate geojson files will be output with the layer name.
For example a topojson containing states and counties:
{
"type": "Topology",
"objects": {
"county": {
"type": "GeometryCollection",
"geometries": [...]
},
"state": {
"type": "GeometryCollection",
"geometries": [...]
}
}
}
would produce two geojson files, output_geo_county.json
and output_geo_state.json
If you experience a "segmentation fault" one thing to try is explained here:
pip install shapely --no-binary shapely
Originally written by sgillies and perrygeo. Converted to Python3 and packaged into a CLI by kylepollina.
Sources:
- https://gist.github.com/perrygeo/1e767e42e8bc54ad7262
- https://github.com/sgillies/topojson/blob/master/topojson.py
License - https://github.com/topojson/topojson/blob/master/LICENSE.md