All examples By author By category About

emeeks

Merge Countries Based on Centroid

One of the advantages of topojson is the ability to merge polygons, but a topojson array doesn't consist of features. So if you wanted to merge features based on their geospatial attributes, you need to use topojson.features() in your filter of your topojson data array so that you can use d3.geo.centroid() or d3.geo.bounds()

In this example, all countries with a centroid that has an X position of less than 0 longitude are merged using the mergeAt() function.