Skip to content

Instantly share code, notes, and snippets.

Last active May 28, 2021
What would you like to do?
Transparent Earth
license: gpl-3.0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
body {
font-family: "Helvetica Neue", sans-serif;
margin: 0;
background: #3a403d;
<script src=""></script>
<script src=""></script>
var width = window.innerWidth, height = window.innerHeight;
var projection = d3.geoOrthographic()
.scale(width / 4.1)
.translate([width / 2, height / 2])
var path = d3.geoPath()
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
var g = svg.append("g");
var graticule = d3.geoGraticule()
.step([10, 10]);
.attr("class", "graticule")
.attr("d", path)
.style("fill", "#fff")
.style("stroke", "#ccc");
d3.timer(function(elapsed) {
projection.rotate([.05 * elapsed - 120, 0, 0]);
g.selectAll("path").attr("d", path);
var c = d3.scaleOrdinal(d3.schemeCategory20);
d3.json("countries.json", function(error, data){
.data(topojson.feature(data, data.objects.polygons).features)
.attr("class", "subunit")
.attr("d", path)
.style("stroke", "#fff")
.style("stroke-width", "1px")
.style("fill", function(d,i){ return c(i); })
.style("opacity", ".6");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment