I'm trying to display some geojson vector features on a leaflet map. The size of my GeoJSON is too big (25.4mb of data, 8.47mb gzipped), so I'm trying to use a TopoJSON format to reduce the size without loosing detail.

I converted my geojson data with topojson tool and just basic params: topojson --id-property okato_code -p name -o adm.topojson adm.json

That significantly reduced the file size (down to 1.54mb of data, 201.3kb gzipped). But when I translate it back ( using topojson.object() ) to GeoJSON on the client, it looks overgeneralized and like it has some incorrect topologies when zooming in. I thought there was no generalization happening during translation to/from topoJSON, then why are the geometries different? How to make them identical? My goal is just to reduce the size of the file without any simplification of geometries.

Here's the map - http://basemap.ru/json/ You have to wait for the big GeoJSON to download, it's included for comparison, but after it loads, you can see a distinct difference on high zoom levels. GeoJSON layer is orange and TopoJSON layer is white. I've included the layer switcher to turn topojson and geojson on and off.

The data itself is here: http://basemap.ru/json/json/adm.geojson http://basemap.ru/json/json/adm.topojson The script with translation is http://basemap.ru/json/mapscript.js

If it makes sense, my map is in Asia Lambert Conformal Conic projection (http://spatialreference.org/ref/esri/102012/)

1 Answer 1


The issue here is TopoJSON’s default quantization behavior; you need to increase the quantization precision if you want to preserve detail when zoomed in. Try -q 1e5 to increase the quantization factor from the default by 10, or -q 1e6 by 100.

The appropriate value of Q depends on the maximum effective size of your map and limited by the original precision of the geometry. Your map appears to have 11 zoom levels by powers of 2, so starting with the smallest size of 560×410 at zoom level 0, the effective size of the map at zoom level 10 is 573,440×419,840. If you want to maintain this precision, you will need Q = 1e6 (and a significantly larger TopoJSON file).

More details: the quantization factor Q determines the maximum number of differentiable points and defaults to 10,000. For best efficiency, Q should be a factor of 10 because digits are base-10 encoded in JSON. The default value is appropriate for displaying a map on a computer screen which typically has at most a resolution of 2,560×1,440 pixels, well under 10,000×10,000. (Q is an upper bound on differentiability; if points are not uniformly spaced, you may get fewer differentiable points.)

TopoJSON uses quantization to determine whether two points are coincident for the purpose of simplification. This is required because GeoJSON does not encode topology, and exact matches would be overly strict due to floating point error in GeoJSON coordinates. Also, quantization is a major factor in reducing the size of the TopoJSON encoding, especially in conjunction with the delta encoding.

Slightly related, here is an example of the Asia Lambert Conic Conformal projection used for Russia.

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.