Creating TopoJSON Files

To roll your own TopoJSON files from a shapefile, you need the ogr2ogr utility from the GDAL library and the topojson package that you can install with npm.

World Countries TopoJSON

First download a shapefile with administrative boundaries without boundary lakes from


Convert the shapefile to GeoJSON.

ogr2ogr -f GeoJSON units.json ne_10m_admin_0_countries_lakes.shp

Convert GeoJSON to Topojson using simplification to reduce file size. The SU_A3 is used as the ID and the name as a property.

topojson --simplify-proportion .08 --id-property SU_A3 -p name=NAME -o countries.json units.json

Fixing Country IDs

Not all the SU_A3 IDs match those used in the ISO_A3 standard. The d3.geomap git repository contains a Python script aptly called to replace the non-matching IDs with the corresponding ISO_A3 values. For more details refer to issue #12.

Countries with Administrative Regions TopoJSON

Download a shapefile with administrative country regions.


To create a Topojson file with US States run:

ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('USA')" units.json ne_10m_admin_1_states_provinces_lakes.shp

topojson --simplify-proportion .08 --id-property fips -p name=name -o USA.json units.json