Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbostock/9876000 to your computer and use it in GitHub Desktop.
Save mbostock/9876000 to your computer and use it in GitHub Desktop.
Merging Counties II
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.land {
fill: #bbb;
stroke: #000;
stroke-linejoin: round;
stroke-linecap: round;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 600;
var projection = d3.geo.albersUsa()
.scale(1280)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("/mbostock/raw/4090846/us.json", function(error, us) {
if (error) throw error;
svg.append("path")
.datum(topojson.merge(us, us.objects.counties.geometries))
.attr("class", "land")
.attr("d", path);
});
d3.select(self.frameElement).style("height", height + "px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment