Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Last active December 19, 2015 15:29
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 robinkraft/5977023 to your computer and use it in GitHub Desktop.
Save robinkraft/5977023 to your computer and use it in GitHub Desktop.
Animated globe and humid tropics, Angola in green.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/topojson.v1.js"></script>
<script src="http://d3js.org/d3.v3.js"></script>
<style>
path {
stroke: white;
stroke-width: 0.25px;
fill: grey;
}
.humid {
fill: rgb(200,50,50);
opacity: .4;
}
.subunit.c24 {
fill:green;
}
</style>
</head>
<body>
<script>
var width = 700, height = 700,
velocity = .007, then = Date.now();
var projection = d3.geo.orthographic()
.center([0, 0])
.clipAngle(90)
.scale(150)
.rotate([0,0]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var path = d3.geo.path()
.projection(projection);
var world = svg.append("svg:g");
var humid = svg.append("svg:g");
var forma = svg.append("svg:g");
d3.json("http://formatemp.s3.amazonaws.com/world.json", function(error, topology) {
world.selectAll("path")
.data(topojson.feature(topology, topology.objects.countries).features)
.enter()
.append("path")
.attr("class", function(d) {return "subunit c" + d.id})
.attr("d", path)
d3.timer(function() {
var angle = velocity * (Date.now() - then);
projection.rotate([angle,0,-23]);
svg.selectAll("path")
.attr("d", path.projection(projection));
})
});
// load and display the humid tropical biome
d3.json("humid.json", function(error, topology) {
humid.selectAll("path")
.data(topojson.feature(topology, topology.objects.humid)
.features)
.enter()
.insert("path")
.attr("class", "humid")
.attr("d", path)
});
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment