Skip to content

Instantly share code, notes, and snippets.

Forked from mbostock/.block
Last active February 9, 2016 02:09
Show Gist options
  • Save mbostock/4525362 to your computer and use it in GitHub Desktop.
Save mbostock/4525362 to your computer and use it in GitHub Desktop.
Two Point Equidistant
license: gpl-3.0

This example demonstrates the unique property of the two-point equidistant projection: great circles centered around either of the two reference points (here Honolulu and Washington, D.C.) are projected as circles.

The projection implementation is still a work in progress, hence the visual artifacts; it requires elliptical clipping.

<!DOCTYPE html>
<meta charset="utf-8">
.land {
fill: #eee;
stroke: #444;
stroke-width: .5px;
.circle {
fill: none;
.circle.a {
stroke: #f00;
.circle.b {
stroke: #00a2f3;
<script src="//"></script>
<script src="//"></script>
<script src="//"></script>
var width = 960,
height = 960;
var a = [-158, 21.5], // Honolulu, HI
b = [-77, 39], // Washington, DC
circle =;
var projection = d3.geo.twoPointEquidistant()
.points([a, b])
.translate([width / 2, height / 2])
var path = d3.geo.path()
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
.attr("class", "circle a")
.data(d3.range(10, 180, 10))
.attr("d", function(r) { return path(circle.origin(a).angle(r)()); });
.attr("class", "circle b")
.data(d3.range(10, 180, 10))
.attr("d", function(r) { return path(circle.origin(b).angle(r)()); });
d3.json("/mbostock/raw/4090846/world-110m.json", function(error, world) {
if (error) throw error;
svg.insert("path", ".circle")
.attr("class", "land")
.attr("d", path);
});"height", height + "px");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment