See shapefile for converting ESRI shapefiles to GeoJSON, ndjson-cli for manipulating newline-delimited JSON streams, d3-geo-projection for manipulating GeoJSON, and topojson-client for manipulating TopoJSON and converting it back to GeoJSON. See also us-atlas and world-atlas for pre-built TopoJSON.
If you use NPM,
npm install topojson-server. Otherwise, download the latest release. You can also load directly from unpkg. AMD, CommonJS, and vanilla environments are supported. In vanilla, a
topojson global is exported:
Returns a TopoJSON topology for the specified GeoJSON objects. The returned topology makes a shallow copy of the input objects: the identifier, bounding box, properties and coordinates of input objects may be shared with the output topology.
If a quantization parameter is specified, the input geometry is quantized prior to computing the topology, the returned topology is quantized, and its arcs are delta-encoded. Quantization is recommended to improve the quality of the topology if the input geometry is messy (i.e., small floating point error means that adjacent boundaries do not have identical values); typical values are powers of ten, such as 1e4, 1e5 or 1e6. See also topojson.quantize to quantize a topology after it has been constructed, without altering the topological relationships.
Converts one or more GeoJSON objects to an output topology. For example, to convert a GeoJSON FeatureCollection in the input file us-states.json to a TopologyJSON topology in the output file us.json:
geo2topo states=us-states.json > us.json
The resulting topology has a “states” object which corresponds to the input geometry. For convenience, you can omit the object name and specify only the output file name; the object name will then be the basename of the file, with the directory and extension removed. For example, to convert the states.json GeoJSON FeatureCollection to a TopologyJSON topology with the “states” object in us.json:
geo2topo states.json > us.json
See also topo2geo.
Output usage information.
Output the version number.
Accept newline-delimited JSON, with one feature per line.
Specify the output TopoJSON file name. Defaults to “-” for stdout.
Specify a pre-quantization paramter. 0 disables quantization. See topojson.topology for a description of quantization.