Cahill-Keyes map projection (I modified Waterman butterfly projection in the geo.polyhedron D3 plugin to have incisions at 17° (Thanks Jason for the great inspiration!).
Gene Keyes's first 5 principles:
The last two points are achieved via the custom projection defined by Gene Keyes which I reimplemented in javascript from original Perl program by Mary Jo Graça.
The last principle to take care of is:
The colouring is inspired (i.e. adapted...ok copied! This is just building on Giants' shoulders: Mike called it For example ;-) from Mike's World Map.
The rendering of Tropic of Cancer/Capricorn and Arctic/Antartic Circle are inspired by Jason's Bartholomew’s Regional Projection.
forked from espinielli's block: Cahill-Keyes map projection
xxxxxxxxxx
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
}
.stroke {
fill: none;
stroke: #000;
stroke-width: 1.5px;
}
.fill {
fill: #ADD8E6;
}
.graticule {
fill: none;
stroke: #777;
stroke-width: .5px;
stroke-opacity: .5;
}
.parallel {
fill: none;
stroke: #000;
stroke-width: .5px;
stroke-dasharray: 2,2;
}
.land {
fill: #none;
stroke: #000;
stroke-width: .5px;
}
.country {
stroke: #000;
stroke-width: .5px;
}
.boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
</style>
<body>
<script src="https://d3js.org/d3.v5.js"></script>
<script src="https://unpkg.com/d3-geo-polygon"></script>
<script src="cahill-keyes.js"></script>
<script src="https://unpkg.com/topojson"></script>
<script>
var width = 960,
height = 380;
var color = d3.scaleOrdinal(d3.schemeCategory10);
var ε = 1e-2,
x0 = 20, // rotation
φ0 = 22.5, // Tropic of Cancer
φ1 = 67.5, // Arctic Circle
graticule = d3.geoGraticule();
var projection = d3.geoPolyhedralCahillKeyes()
.center([0,0])
.rotate([x0, 0])
.scale(0.022)
.translate([width / 2, height / 2 - 60])
.precision(.1);
var path = d3.geoPath()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var defs = svg.append("defs");
defs.append("path")
.datum({type: "Sphere"})
.attr("id", "sphere")
.attr("d", path);
defs.append("clipPath")
.attr("id", "clip")
.append("use")
.attr("xlink:href", "#sphere");
svg.append("use")
.attr("class", "stroke")
.attr("xlink:href", "#sphere");
svg.append("use")
.attr("class", "fill")
.attr("xlink:href", "#sphere");
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("clip-path", "url(#clip)")
.attr("d", path);
svg.selectAll("path.parallel")
.data([
d3.range(-180, 181, 1).map(function(x) { return [x - x0, φ0]; }),
d3.range(-180, 181, 1).map(function(x) { return [x - x0, φ1]; }),
d3.range(-180, 181, 1).map(function(x) { return [x - x0, -φ0]; }),
d3.range(-180, 181, 1).map(function(x) { return [x - x0, -φ1]; }),
[[-180, 0], [-60, 0], [60, 0], [180, 0]]
])
.enter().append("path")
.datum(function(d) { return {type: "LineString", coordinates: d}; })
.attr("class", "parallel")
.attr("clip-path", "url(#clip)")
.attr("d", path);
d3.json("https://gist.githubusercontent.com/mbostock/4090846/raw/world-110m.json")
.then(function(world) {
var countries = topojson.feature(world, world.objects.countries).features,
neighbors = topojson.neighbors(world.objects.countries.geometries);
svg.selectAll(".country")
.data(countries)
.enter().insert("path", ".graticule")
.attr("class", "country")
.attr("clip-path", "url(#clip)")
.attr("d", path)
.style("fill", function(d, i) {
if (d.id == 10 || d.id == 304) // make Antartica and Greenland white
return d3.rgb("white");
return color(d.color = d3.max(neighbors[i], function(n) { return countries[n].color; }) + 1 | 0);
});
svg.insert("path", ".graticule")
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
.attr("class", "boundary")
.attr("clip-path", "url(#clip)")
.attr("d", path);
});
d3.select(self.frameElement).style("height", height + "px");
</script>
https://d3js.org/d3.v5.js
https://unpkg.com/d3-geo-polygon
https://unpkg.com/topojson