Skip to content

Instantly share code, notes, and snippets.

@Fil
Last active June 19, 2017 20:44
Show Gist options
  • Save Fil/3a184f1e6e90e2d38a5e54a8223fcd63 to your computer and use it in GitHub Desktop.
Save Fil/3a184f1e6e90e2d38a5e54a8223fcd63 to your computer and use it in GitHub Desktop.
Fuzzy Counties d3v4 [UNLISTED]
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: none;
stroke: steelblue;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<script>
var width = 960,
height = 500;
var projection = d3.geoAlbersUsa()
.scale(1000)
.translate([width / 2, height / 2]);
var path = d3.geoPath()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("https://gist.githubusercontent.com/mbostock/4090846/raw/d534aba169207548a8a3d670c9c2cc719ff05c47/us.json", function(error, us) {
if (error) throw error;
svg.append("path")
.attr("d", path({
type: "MultiLineString",
coordinates: topojson.feature(us, us.objects.counties).features
.filter(function(d) { return d.geometry && d.geometry.coordinates.length; })
.map(d3.geoBounds)
}));
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment