Skip to content

Instantly share code, notes, and snippets.

@fasiha
Created June 18, 2013 18:27
Show Gist options
  • Save fasiha/5807962 to your computer and use it in GitHub Desktop.
Save fasiha/5807962 to your computer and use it in GitHub Desktop.
Maximal coverage satellite projection
{"description":"Maximal coverage satellite projection","endpoint":"","display":"svg","public":true,"require":[{"name":"projection","url":"http://d3js.org/d3.geo.projection.v0.min.js"},{"name":"topojson","url":"http://d3js.org/topojson.v0.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world110.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"us.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/hZFispE.png"}
//http://www.nytimes.com/interactive/2013/03/01/world/americas/border-graphic.html
var svg = d3.select("svg");
var width = tributary.sw;
var height = tributary.sh;
var world = tributary.world110;
var countries = topojson.object(world, world.objects.countries)
var us = tributary.us;
//var states = topojson.object(us, us.objects.land);
var globe = {type: "Sphere"};
var d = 2387.0288;
var projection = d3.geo.satellite()
.distance(d)
.scale(273)
.rotate([-70, -30, -0])//-long,-lat,rot clockwise from north
.center([0, 0])
.translate([455,320])
.tilt(0)
.clipAngle(Math.acos(1 / d) * 180 / Math.PI - 1e-6);
//var projection = d3.geo.mercator()
//.scale(650)
// The reference 74ºW, 41ºN is at 181px, 710px.
//var offset = projection.translate([-181, -710])([-74, 41]);
//projection.translate([-offset[0], -offset[1]]);
//alert(([0.0,0.0]))
var graticule = d3.geo.graticule()
.step([30, 30]);
var path = d3.geo.path()
.projection(projection);
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path)
;
svg.append("path")
.datum(countries)
.attr("class", "land")
.attr("d", path);
.graticule {
fill: none;
stroke: red;
}
.land {
fill: #787985;
fill-opacity: .8;
stroke: #000;
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment