The Orthographic projection is available as d3.geo.orthographic
in the geo.projection D3 plugin.
-
-
Save mdsumner/576a8ed652c4cf45eac7320ab13c8e1f to your computer and use it in GitHub Desktop.
Adaptive Resampling
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> | |
<meta charset="utf-8"> | |
<style> | |
.background { | |
fill: #a4bac7; | |
} | |
.foreground { | |
fill: none; | |
stroke: #333; | |
stroke-width: 1.5px; | |
} | |
.graticule { | |
fill: none; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
.graticule:nth-child(2n) { | |
stroke-dasharray: 2,2; | |
} | |
.land { | |
fill: #d7c7ad; | |
stroke: #766951; | |
} | |
.boundary { | |
fill: none; | |
stroke: #a5967e; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v2.min.js"></script> | |
<script src="https://raw.github.com/d3/d3-plugins/clip/geo/projection/projection.js"></script> | |
<script src="https://raw.github.com/d3/d3-plugins/clip/geo/clip/clip.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var path = d3.geo.path() | |
.projection(d3.geo.orthographic() | |
.translate([width / 2 - .5, height / 2 - .5])); | |
var clip = d3.geo.clip(); | |
var graticule = d3.geo.graticule() | |
.extent([[-90, -90], [90, 90]]); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("path") | |
.datum(graticule.outline) | |
.attr("class", "background") | |
.attr("d", clipPath); | |
svg.selectAll(".graticule") | |
.data(graticule.lines) | |
.enter().append("path") | |
.attr("class", "graticule") | |
.attr("d", clipPath); | |
svg.append("path") | |
.datum(graticule.outline) | |
.attr("class", "foreground") | |
.attr("d", clipPath); | |
d3.json("/d/3682676/readme-boundaries.json", function(collection) { | |
svg.insert("g", ".graticule") | |
.attr("class", "boundary") | |
.selectAll("path") | |
.data(collection.features) | |
.enter().append("path") | |
.attr("d", clipPath); | |
}); | |
d3.json("/d/3682676/readme-land.json", function(collection) { | |
svg.insert("g", ".graticule,.boundary") | |
.attr("class", "land") | |
.selectAll("path") | |
.data(collection.features) | |
.enter().append("path") | |
.attr("d", clipPath); | |
}); | |
function clipPath(d) { return path(clip(d)); } | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment