d3wannabe
d3wannabe

Reputation: 1317

Simplify topojson via command line tool

I'm trying to simplify "world-110m.json" as mentioned in this thread...

Topojson: quantization VS simplification

Which also references the documentation...

https://github.com/mbostock/topojson/wiki/Command-Line-Reference

I've got the tool installed but am really struggling to find an example input that works for me (even with the mentioned documentation). For example, I'm trying to do something like...

"topojson -s 1e5 -o output.json --world-110m.json"

But it's just hanging.

The reasons I want to try simplifying world-110m.json are...

1) Sometimes I display a rotating d3 globe that's so tiny that it doesn't need detailed coordinates mapped (just a basic outline of the continents really) - and so the full world-110m.json file I'm using is unnecessarily draining.

2) Sometimes the globe is larger and works nicely on a desktop, but not via a mobile device so I want to see how much I can simplify/quantise the data to help with performance.

Hopefully I'm looking in the right place with the topojson command line tool, but either way I appreciate any thoughts!

Upvotes: 2

Views: 919

Answers (1)

Jefferson Neves
Jefferson Neves

Reputation: 41

You can use toposimplify library, by mbostock. Here's an example:

toposimplify -o output_file.json -P 0.5 original_file.json

The param number for -P specifies simplification threshold value as the minimum quantile of planar triangle areas. The closer this number is to 0, smaller will be the output file size.

Upvotes: 4

Related Questions