1.0.0 • Published 8 years ago
projections v1.0.0
projections
Collection of (stereographic) map projections. See this Wikipedia list.
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
Projection | Full name | Available options | Map height* |
---|---|---|---|
braun | Braun stereographic | meridian , latLimit | |
central-cylindrical | Central cylindrical | meridian , latLimit | |
equirectangular | Equirectangular | meridian , standardParallel | 1 / 2 |
gall | Gall stereographic | meridian , latLimit | |
gall-peters | Gall–Peters | meridian | 2 / π |
kavrayskiy-7 | Kavrayskiy VII | meridian | 1 / √3 |
lambert | Lambert cylindrical equal-area | meridian | 1 / π |
mercator | Mercator (Web) | meridian , latLimit | |
miller | Miller cylindrical | meridian , latLimit | |
sinusoidal | Sinusoidal | meridian | 1 / 2 |
wagner-6 | Wagner VI | meridian | 1 / 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
Option | description | Default |
---|---|---|
meridian | Latitude of the central meridian | 0 |
latLimit | maximum latitude in degrees < 90 | 85 |
standardParallel | longitude 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.