Skip to content

Instantly share code, notes, and snippets.

@mbostock
Forked from mbostock/.block
Last active February 9, 2016 01:37
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 mbostock/3791255 to your computer and use it in GitHub Desktop.
Save mbostock/3791255 to your computer and use it in GitHub Desktop.
Satellite Projection Test
license: gpl-3.0

Figure 37.—Tilted Perspective projection. Eastern seaboard viewed from a point about 160 km above Newburg, N.Y. Parameters using symbols in text: φ₁ = 41º 30′ N. lat, λ₀ = 74º 00′ W. long., ω = 55º, γ = 210º, P = 1.025. 1º graticule.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: auto;
padding: 10px;
width: 537px;
}
svg {
background: url(readme.png) no-repeat;
border: solid 1px #000;
}
.graticule {
fill: none;
stroke: red;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script>
<script>
var width = 537,
height = 737;
var projection = d3.geo.satellite()
.distance(1.025)
.scale(38800)
.rotate([74, -41.5, 212])
.tilt(55);
// The reference 74ºW, 41ºN is at 181px, 710px.
var offset = projection.translate([-181, -710])([-74, 41]);
projection.translate([-offset[0], -offset[1]]);
var graticule = d3.geo.graticule()
.extent([[-74 - 15, 41 - 15], [-74 + 1e-6, 41 + 1e-6]])
.step([1, 1]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
d3.select(self.frameElement).style("height", height + 20 + "px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment