<!DOCTYPE html> <meta charset="utf-8"> <style> body { background: #fcfcfa; } .stroke { fill: none; stroke: none; } .fill { fill: none; } .graticule { fill: none; stroke: none; } .land { fill: none; stroke: #000; stroke-width: .5px; } .boundary { fill: none; stroke: #000; stroke-width: .5px; } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="http://d3js.org/d3.geo.polyhedron.v0.min.js"></script> <script src="http://d3js.org/topojson.v1.min.js"></script> <script> var width = 960, height = 550; var projection = d3.geo.polyhedron.waterman() .rotate([30, -20]) .scale(150) .translate([width / 2, height / 2]) .precision(.1); var path = d3.geo.path() .projection(projection); var graticule = d3.geo.graticule(); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); var defs = svg.append("defs"); defs.append("path") .datum({type: "Sphere"}) .attr("id", "sphere") .attr("d", path); defs.append("clipPath") .attr("id", "clip") .append("use") .attr("xlink:href", "#sphere"); svg.append("use") .attr("class", "stroke") .attr("xlink:href", "#sphere"); svg.append("use") .attr("class", "fill") .attr("xlink:href", "#sphere"); svg.append("path") .datum(graticule) .attr("class", "graticule") .attr("clip-path", "url(#clip)") .attr("d", path); d3.json("countries_lakes_50m.json", function(error, world) { console.log(world); svg.insert("path", ".graticule") .datum(topojson.mesh(world, world.objects.ne_50m_admin_0_countries_lakes, function(a, b) { return a == b; })) .attr("class", "land") .attr("clip-path", "url(#clip)") .attr("d", path); svg.insert("path", ".graticule") .datum(topojson.mesh(world, world.objects.ne_50m_admin_0_countries_lakes, function(a, b) { return a !== b; })) .attr("class", "boundary") .attr("clip-path", "url(#clip)") .attr("d", path); }); d3.select(self.frameElement).style("height", height + "px"); </script>