block by emeeks 10567716

Merge Countries Based on Centroid

Full Screen

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.

index.html