Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 02:03
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/5952814 to your computer and use it in GitHub Desktop.
Save mbostock/5952814 to your computer and use it in GitHub Desktop.
Alaska Albers
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.graticule {
fill: none;
stroke: #777;
stroke-width: .5px;
stroke-opacity: .5
}
.land {
fill: #222;
}
.boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
</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 = 500;
// EPSG:3338
var projection = d3.geo.conicEqualArea()
.scale(1400)
.rotate([154, 0])
.center([0, 62])
.parallels([55, 65])
.clipExtent([[-1, -1], [width + 1, height + 1]]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var graticule = d3.geo.graticule()
.step([2, 2]);
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
d3.json("/mbostock/raw/4090846/us.json", function(error, us) {
if (error) throw error;
var alaskaState = us.objects.states.geometries.filter(function(d) { return d.id === 2; })[0],
alaskaCounties = us.objects.counties.geometries.filter(function(d) { return d.id / 1000 | 0 === 2; });
svg.insert("path", ".graticule")
.datum(topojson.feature(us, alaskaState))
.attr("class", "land")
.attr("d", path);
svg.insert("path", ".graticule")
.datum(topojson.mesh(us, {type: "GeometryCollection", geometries: alaskaCounties}))
.attr("class", "boundary")
.attr("d", path);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment