d3-geo-projection

Extended geographic projections for D3.js.

npm install d3-geo-projection
39 downloads in the last day
300 downloads in the last week
1 314 downloads in the last month

Extended Geographic Projections

airy
aitoff
albers
albersUsa
armadillo
august
azimuthalEqualArea
azimuthalEquidistant
baker
berghaus
boggs
bonne
bromley
chamberlin
collignon
conicEqualArea
conicConformal
conicEquidistant
craig
craster
cylindricalEqualArea
cylindricalStereographic
eckert1
eckert2
eckert3
eckert4
eckert5
eckert6
eisenlohr
equirectangular
fahey
gilbert
ginzburg4
ginzburg5
ginzburg6
ginzburg8
ginzburg9
gnomonic
gringorten
guyou
hammer
hammerRetroazimuthal
healpix
hill
homolosine
kavrayskiy7
lagrange
larrivee
laskowski
littrow
loximuthal
mercator
miller
modifiedStereographic
mollweide
mtFlatPolarParabolic
mtFlatPolarQuartic
mtFlatPolarSinusoidal
naturalEarth
nellHammer
orthographic
peirceQuincuncial
polyconic
polyhedron.butterfly
polyhedron.waterman
rectangularPolyconic
robinson
satellite
sinuMollweide
sinusoidal
stereographic
times
twoPointAzimuthal
twoPointEquidistant
transverseMercator *
vanDerGrinten
vanDerGrinten2
vanDerGrinten3
vanDerGrinten4
wagner4
wagner6
wagner7
wiechel
winkel3

Projections:

This plugin also provides d3.geo.interrupt, which can be used to create arbitrary interrupted projections from a given raw projection. For example, see Philbrick’s interrupted Sinu-Mollweide.

This plugin requires D3 3.0 or greater. To use the official hosted version, include the projection plugin after including D3:

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/d3.geo.projection.v0.min.js" charset="utf-8"></script>

Alternatively, you can clone this repo, download the zipball, or right-click d3.geo.projection.v0.min.js and save.

To use this plugin within a Node.js context, you can npm install d3 d3-geo-projection and then say:

var d3 = require("d3");

require("d3-geo-projection")(d3);

Subsequently, d3.geo will contain all the extended projections.

Defining a New Projection

First define your raw projection function:

function cosinusoidal(λ, φ) {
  return [λ * Math.sin(φ), φ];
}

cosinusoidal.invert = function(x, y) {
  return [x / Math.sin(y), y];
};

Then create a constructor using d3.geo.projection:

d3.geo.cosinusoidal = function() {
  return d3.geo.projection(cosinusoidal);
};

You can optionally expose the raw projection to facilitate composite projections:

(d3.geo.cosinusoidal = function() {
  return d3.geo.projection(cosinusoidal);
}).raw = cosinusoidal;
npm loves you