# mproj

> A JavaScript port of the Proj.4 cartographic projections library

Latest version **0.1.6** (published 2026-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install mproj
pnpm add mproj
yarn add mproj
bun add mproj
```

Provides the commands `mproj`, `mcs2cs`.

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2026-08-01 |
| First published | 2016-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=0.12.0 |
| Dependencies | 2 |
| Unpacked size | 3.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | Matthew Bloch |
| Maintainers | mbloch |
| Keywords | projections, proj4, cartography |

## Links

- npm: https://www.npmjs.com/package/mproj
- Repository: https://github.com/mbloch/mapshaper-proj
- Homepage: https://github.com/mbloch/mapshaper-proj#readme
- Issues: https://github.com/mbloch/mapshaper-proj/issues
- npm.io page: https://npm.io/package/mproj

## Dependencies (2)

- [rw](https://npm.io/package/rw.md) ~1.3.2
- [geographiclib](https://npm.io/package/geographiclib.md) 1.48.0

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.1.6 (latest) — 2026-08-01
- 0.1.5 — 2026-07-10
- 0.1.4 — 2026-07-09
- 0.1.3 — 2026-05-23
- 0.1.2 — 2026-05-02
- 0.1.1 — 2026-05-01
- 0.1.0 — 2026-05-01
- 0.0.40 — 2024-11-19
- 0.0.39 — 2024-04-13
- 0.0.38 — 2024-04-03
- 0.0.37 — 2023-06-24
- 0.0.36 — 2023-04-07
- 0.0.35 — 2021-12-09
- 0.0.34 — 2021-05-30
- 0.0.33 — 2021-05-24
- … 32 more at https://npm.io/package/mproj/versions

## README

# mapshaper-proj

This software is a JavaScript port of v4.9.3 of the [Proj.4](http://proj4.org/) map projection library. Although it was created to be used by [mapshaper](https://github.com/mbloch/mapshaper), all are welcome to use and improve it.

Why create another Proj.4 port, when there is already [proj4js](https://github.com/proj4js/proj4js)? Unlike proj4js, this port is a very literal translation to JavaScript, so staying up-to-date with future changes to Proj.4 should be relatively simple. Also, this software's output is more consistent with Proj.4's output.

##### Missing features

* No support for datum transformations using grid files.

* About 1/5 of Proj.4's 130-odd projections have not been ported.


## Command line programs: mproj and mcs2cs

These are workalike versions of the `proj` and `cs2cs` programs from Proj.4.

To install the current versions system-wide, run `npm install -g mproj`.


## Node API

The software can be used in either the Proj.4 style or the proj4js style.

##### proj4js style

```
var proj = require('mproj');
# create functions for translating between two coordinate systems
# returned object has forward() and inverse() functions
var obj = proj(<source definition>, <dest definition>);

# WGS84 is assumed if a source definition is not given
var obj = proj(<dest definition>);

# a shortcut for translating a single point
# <point> is an [x, y] array or an object with x and y properties
var xy = proj([<source definition>,] dest definition, <point>);
```

See the [proj4js.org website](http://proj4js.org/) for more detailed help.

##### Proj.4 style

```
var proj = require('mproj');
# create a projection object from a proj4 string
var P = proj.pj_init(<proj4 crs definition>);

# project and inverse-project geographical coordinates
var xy = proj.pj_fwd({lam: <longitude in radians>, phi: <latitude in radians>}, P);
var lp = proj.pj_inv({x: <easting in meters>, y: <northing in meters>}, P);

# transform arrays of coordinates from one coordinate system to another
proj.pj_transform(<source crs>, <dest crs>, <x array>, <y array>[, <z array>]);
```

##### Error handling
The x and y coordinates of unprojectable points are set to `Infinity`. Other errors cause an Error to be thrown containing an appropriate message.


## Building

mapshaper-proj now uses Rollup to build from the legacy shared-scope source graph. This preserves the original C-ported structure while producing both CommonJS and ESM outputs.

Running `node build` creates a build containing all supported projections in the `dist/` directory.

Running `node build merc,lcc,aea` creates a build containing only the listed projections. You can customize the comma-separated list to include only the projections that you want. Run `mproj -l` to see a list of all supported projections.

Running `node build -m` creates the minimal build.

Running `node build -f` watches files and rebuilds on change.

Build artifacts:

* `dist/mproj.js` (CommonJS)
* `dist/mproj.mjs` (ESM)
* `dist/mproj-minimal.js` and `dist/mproj-minimal.mjs`
* `dist/mproj-custom.js` and `dist/mproj-custom.mjs` (for custom projection lists)

---
_Source: https://npm.io/package/mproj · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
