The Winkel I projection, with a "latitude of truescale" defined at 45°.
Last active
April 5, 2017 20:16
-
-
Save mthh/0cd16f2d07c723c7dae088e40f0323d0 to your computer and use it in GitHub Desktop.
Winkel 1 projection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 | |
border: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.graticule { | |
fill: none; | |
stroke: #777; | |
stroke-width: 0.5px; | |
stroke-opacity: 0.5; | |
} | |
.land { | |
fill: #222; | |
} | |
.boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: 0.5px; | |
} | |
</style> | |
<svg width="960" height="500"></svg> | |
<script src="//d3js.org/d3.v4.min.js"></script> | |
<script src="//d3js.org/topojson.v2.min.js"></script> | |
<script src="winkel1.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"), | |
g = svg.append("g"); | |
var projection = d3.geoProjection(winkel1Raw(45)) | |
.scale(140) | |
.translate([width / 2, height / 2]) | |
.precision(0.1); | |
var path = d3.geoPath() | |
.projection(projection); | |
var graticule = d3.geoGraticule(); | |
g.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path); | |
g.append("path") | |
.datum({type: "Sphere"}) | |
.attr("class", "sphere") | |
.attr("d", path) | |
.attr("fill", "none") | |
.attr("stroke", "black"); | |
d3.json("world-50m.json", function(error, world) { | |
if (error) throw error; | |
g.insert("path", ".graticule") | |
.datum(topojson.feature(world, world.objects.land)) | |
.attr("class", "land") | |
.attr("d", path); | |
g.insert("path", ".graticule") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; })) | |
.attr("class", "boundary") | |
.attr("d", path); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cos = Math.cos; | |
function winkel1Raw(lat_truescale) { | |
var cosphi1 = lat_truescale ? cos(lat_truescale) : 0; | |
function forward(lambda, phi) { | |
var x = lambda, y = phi; | |
return [0.5 * x * (cosphi1 + cos(phi)), y]; | |
} | |
forward.invert = function(x, y) { | |
var lambda = x, phi = y; | |
return [2 * lambda / (cosphi1 + cos(phi)), phi]; | |
}; | |
return forward; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment