Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created June 29, 2016 01:49
Show Gist options
  • Save wboykinm/cda37c024fdb666c1f0786179f11c3b9 to your computer and use it in GitHub Desktop.
Save wboykinm/cda37c024fdb666c1f0786179f11c3b9 to your computer and use it in GitHub Desktop.
Satellite Projection
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.graticule {
fill: none;
stroke: #777;
}
.boundary {
fill: #ccc;
fill-opacity: .8;
stroke: #000;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 560,
height = 960;
var projection = d3.geo.satellite()
.distance(4.48)
.scale(574)
.rotate([108.44, -39.4, -38])
.center([1.92, 2.96])
.tilt(67)
.clipAngle(45)
.precision(0.108);
var graticule = d3.geo.graticule()
.extent([[-93, 27], [-47 + 1e-6, 57 + 1e-6]])
.step([3, 3]);
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.json("https://gist.githubusercontent.com/mbostock/4090846/raw/d534aba169207548a8a3d670c9c2cc719ff05c47/us-land.json", function(error, us) {
if (error) throw error;
svg.append("path")
.datum(topojson.feature(us, us.objects.land))
.attr("class", "boundary")
.attr("d", path);
});
d3.select(self.frameElement).style("height", height + "px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment