I have been investigating using TopoJSON files to map floor plans for various buildings. As GeoJSON these files render perfectly, however after converting to TopoJSON they are missing a lot of the lines used to render them and the number of geometries is much less than the number of features in the GeoJSON.

I experimented by increasing the quantize parameter but after a certain point it doesn't add any more detail. Is it possible to convert from GeoJSON to TopoJSON without having my features quantized?

1 Answer 1


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°.

  • The files that I am using come originally from cad files and are using a Local Coordinate system, and all of my attempts to convert the file into epsg:4362 using ogr2ogr or qgis render exactly the same file as the one I started with. That file can be found at [link]b3nson.net/marketart/asMapJSON/surf13_l.json also an example of the topoJSON mapped next to the geoJSON can be found at [link]b3nson.net/marketart/asMapJSON/q1e9.htm , although it takes a minute to load. I am big fan of your work, thanks so much for your first reply.
    – Alex Muro
    Mar 13, 2013 at 15:56
  • You'll need a .prj file to convert from that coordinate system to EPSG:4362.
    – mbostock
    Mar 13, 2013 at 16:36
  • Also, I filed a related feature request for topojson.
    – mbostock
    Mar 13, 2013 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.