TopoJSON uses fixed-precision integer coordinates, so no, you can’t create a TopoJSON file without first quantizing coordinates. The precision is controlled with the -q
argument to topojson
, as described in the command-line reference.
(Edit: as of TopoJSON 1.4, you can now construct lossless TopoJSON without quantization by saying --no-quantization
(or equivalently -q 0
).)
That said, it doesn’t sound like quantization is your problem here. Instead, I would guess that your input coordinates are not in WGS84 / EPSG:4326. I would use ogr2ogr to convert your geometry to spherical coordinates in degrees before converting to TopoJSON. For example:
ogr2ogr -f 'ESRI Shapefile' -t_srs EPSG:4326 input-fixed.shp input.shp
topojson -o output.json -- input-fixed.shp
Quantization is unlikely to be the problem here because quantization is localized to the input features’ bounding box, and thus automatically adapts to both small and large features. If you have a map of a very small space (such as building floor plans, and not the western hemisphere), the quantized coordinates will be correspondingly more precise, even at the same value of Q (topojson
's -q
), because the scale of the topology’s transform will be that much larger.
For example, say the bounding box of your input features is [[-122.395, 37.794], [-122.391, 37.797]], approxiamtely San Francisco’s Ferry Building. And say you used the default Q = 10,000. The quantized fixed coordinate [0,0] then maps to [-122.395, 37.794], and the fixed coordinate [9999,9999] maps to [-122.391, 37.797]. In other words, each increment in longitude corresponds to approximately 0.0000004° (4e-7), a tiny amount.
In contrast, with a world map spanning [[-180, -90], [180, 90]] at the same Q = 10,000, each increment in longitude corresponds to approximately 0.036°.
Best Answer
You can use topojson.merge to do this, as shown in bl.ocks.org/5416405:
There are a few limitations to this approach (such as its dependence on an exact topology and lack of detection of holes), but it might for you as-is or with a few adjustments.
There is also the simpler approach of drawing the set of polygons for each region twice, once with a stroke and once with a fill, as shown in bl.ocks.org/5416440:
See also a very similar question on Stack Overflow.