Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Forked from mbostock/.block
Last active December 20, 2015 18:49
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 jfirebaugh/6179171 to your computer and use it in GitHub Desktop.
Save jfirebaugh/6179171 to your computer and use it in GitHub Desktop.
Geocake Model
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<style>
path {
fill: none;
stroke-linejoin: round;
}
.sphere,
.graticule {
stroke: #fff;
stroke-width: 2px;
}
.sphere {
fill: #086FA1;
}
.land {
fill: #FFBE73;
}
</style>
<script>
var width = 960,
height = 500;
var projection = d3.geo.orthographic()
.scale(250)
.translate([width / 2, height / 2])
.rotate([102, -24])
.clipAngle(90);
var path = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule()
.step([20, 20]);
var λ = d3.scale.linear()
.domain([0, width])
.range([-180, 180]);
var φ = d3.scale.linear()
.domain([0, height])
.range([90, -90]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("/d/4090846/world-110m.json", function(error, world) {
svg.append("path")
.datum({type: "Sphere"})
.attr("class", "sphere")
.attr("d", path);
svg.append("path")
.datum(topojson.feature(world, world.objects.land))
.attr("class", "land")
.attr("d", path);
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment