Last active
December 19, 2015 15:29
-
-
Save robinkraft/5977023 to your computer and use it in GitHub Desktop.
Animated globe and humid tropics, Angola in green.
This file contains hidden or 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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment