Skip to main content
100%

Merging TopoJSON states

✓ Published0🌍 Public
AAlan McConchie
Last edited Jun 15, 2016
Created on Jul 18, 2014

This example demonstrates merging multiple polygons into a single polygon using topojson.merge, a feature introduced in TopoJSON 1.6. It displays a pre-projected map of the USA and Canada, highlighting a selected set of states (AK, YT, BC, WA, OR, CA) in orange by merging their geometries into one continuous shape, which removes interior borders between the selected regions. The map also shows all states in gray with white boundary lines drawn via topojson.mesh. Unlike mbostock's original approach of drawing polygons twice, this uses a null projection since the TopoJSON file is already projected, simplifying the code. The selection is hard-coded as a d3.set of state/province IDs, and the merged geometry is rendered as a single SVG path using topojson.merge. This technique is useful for highlighting multi-part regions while preserving a clean, borderless outline.

AI-generated description

This demonstrates using topojson.merge, a new feature in TopoJSON 1.6, to merge multiple polygons into a single polygon whilst removing interior borders. (An alternative approach is to draw the polygons twice.)

Unlike mbostock's original example, this uses a pre-projected topojson file and a null projection.

Similar vizzes