Skip to content

Instantly share code, notes, and snippets.

@mbostock
Forked from mbostock/.block
Last active January 8, 2020 03:25
Show Gist options
  • Save mbostock/3757119 to your computer and use it in GitHub Desktop.
Save mbostock/3757119 to your computer and use it in GitHub Desktop.
Equirectangular (Plate Carrée)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.background .line {
fill: #a4bac7;
}
.foreground .line {
fill: none;
stroke: #333;
stroke-width: 1.5px;
}
.line {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
.line:nth-child(2n) {
stroke-dasharray: 2,2;
}
.land {
fill: #d7c7ad;
stroke: #766951;
}
.boundary {
fill: none;
stroke: #a5967e;
}
</style>
<body>
<script src="http://d3js.org/d3.v2.min.js"></script>
<script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script>
<script>
var width = 960,
height = 500;
var projection = d3.geo.aitoff()
.translate([width / 2 - .5, height / 2 - .5]);
var path = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("g")
.attr("class", "background")
.call(graticule.outline);
svg.append("g")
.attr("class", "graticule")
.call(graticule);
svg.append("g")
.attr("class", "foreground")
.call(graticule.outline);
d3.json("/d/3682676/readme-boundaries.json", function(collection) {
svg.insert("g", ".graticule")
.attr("class", "boundary")
.selectAll("path")
.data(collection.features)
.enter().append("path")
.attr("d", path);
});
d3.json("/d/3682676/readme-land.json", function(collection) {
svg.insert("g", ".graticule,.boundary")
.attr("class", "land")
.selectAll("path")
.data(collection.features)
.enter().append("path")
.attr("d", path);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment