How can GeoJSON data to TopoJSON be converted?
TopoJSON files are often smaller than GeoJSON and the conversion allows you to incrementally simplify a dataset, if you wish.
Glad you asked, oh handsome OP.
topojson
From the command line (Mac OSX 10.8, assumes homebrew installed):
brew install node.js
npm install -g topojson
topojson -o output.json input.json
The function to create a topojson from a geojson in topojson has been moved to geo2topo
npm install topojson-server -g
geo2topo input.geojson > output.topojson
not recognized
error when trying to run geo2topo
after running npm install topojson-server
I ported the TopoJSON code from JavaScript to Python, following the exact same format Mike uses in his library (along with his +300 tests).
If you feel better with Python, just install the library by running:
pip install pytopojson
And then run:
python geo2topo.py geojson_file
You can also use a quantization parameter. Just use the -h
argument to see how it works.
Let me know if this was helpful to you!
I have found pretty good online tool for simplifying geospatial data (including GeoJSON) and export to various formats (including TopoJSON) at https://geoprocessing.online/tool/simplify-polygons/. You can upload the GeoJSON, set simplification level and export to TopoJSON. For more information on data size reduction, see this article: https://kb.geoczech.org/knowledge-base/how-to-reduce-size-of-vector-data/
topojson -o output_file.json input_file.json
works for me under 1.1.0 and 1.4.0. Perhaps you can ask a formal question on here with more info on the problem you're having? Cheers!