Effective Tool Usage
If you're looking to work with Topojson using the command line, it's important to acquaint yourself with the concise and well-crafted API documentation before diving in.
Clarification on Commands
topojson input.json >> output.json # wondering about the meaning of `>>`?
Consulting the topojson user manual reveals that the recommended practice is to utilize >
rather than >>
, as the latter signifies "append to the output file." This discrepancy might be causing the issue at hand.
Streamlined Data Conversion
topojson input.json > output.json # transforming geo data into topojson format.
This command maintains the original data quality from the geojson input while resulting in a +250MB topojson file. However, when processed through d3js on the client side, d3.topojson
attempts to convert it back to geojson (1.4GB!), leading to the generation of an almost 1GB svg in your browser. Not only is this workflow taxing and potentially crashing, but also redundant: topojson serves the purpose of simplifying gis data for compatibility with web browsers' lower capacities. Considering that HD screens operate within 1980*1280 dimensions, gis data typically surpasses this threshold and hence requires simplification.
Optimizing Commands for Efficiency
The key lies in employing the topojson command line to effectively simplify extensive geojson datasets. One common approach involves utilizing -q 1e4
:
topojson -q 1e4 \
-o out.json \
-- input.geojson
This results in an output file with a pseudo-pixel quality equivalent to 10,000 pixels, significantly lower than the input yet adequate for client-side dataviz purposes, all while maintaining a filesize of around or under 1MB.