1.0.0 • Published 7 years ago

projections v1.0.0

Weekly downloads
301
License
MIT
Repository
github
Last release
7 years ago

projections

Collection of (stereographic) map projections. See this Wikipedia list.

npm version Build Status dependency status dev dependency status license

Installation

npm install --save projections

Usage

const projections = require('projections') // for all projections
const mercator = require('projections/mercator') // for a specific projection

WGS to map coordinates

const {x, y} = mercator({lon: 13.5, lat: 52.4})
// x ≊ 0.53722
// y ≊ 0.32686

Given an object containing lon and lat, mercator returns an object {x: …, y: …} (0 ≤ x ≤ 1). For details on the range of y, see the map height column in the projections table.

Map coordinates to WGS

const {lon, lat} = mercator({x: 0.53722, y: 0.32686})
// lon ≊ 13.5
// lat ≊ 52.4

Given an object containing x and y (0 ≤ x ≤ 1), mercator returns an object {lon: …, lat: …}.

Be sure to use the same options everytime you're converting coordinates back and forth to get correct results.

Projections

ProjectionFull nameAvailable optionsMap height*
braunBraun stereographicmeridian, latLimit
central-cylindricalCentral cylindricalmeridian, latLimit
equirectangularEquirectangularmeridian, standardParallel1 / 2
gallGall stereographicmeridian, latLimit
gall-petersGall–Petersmeridian2 / π
kavrayskiy-7Kavrayskiy VIImeridian1 / √3
lambertLambert cylindrical equal-areameridian1 / π
mercatorMercator (Web)meridian, latLimit
millerMiller cylindricalmeridian, latLimit 
sinusoidalSinusoidalmeridian1 / 2
wagner-6Wagner VImeridian1 / 2

* If the projection uses a latitude limit, the map height is the value of y at {lon: meridian, lat: -latLimit}. Otherwise it is the value of y at {lon: meridian, lat: -90}.

Options

OptiondescriptionDefault
meridianLatitude of the central meridian0
latLimitmaximum latitude in degrees < 9085
standardParallellongitude of the standard parallel(s)0

Contributing

If you found a bug, want to propose a feature or feel the urge to complain about your life, feel free to visit the issues page.