# coordinates2pixels

> converts coordinates in format EPSG:4326 to pixel coordinates

Latest version **1.0.0** (published 2015-12-23) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-12-23 |
| First published | 2015-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jorge Godoy |
| Maintainers | jfgodoy |
| Keywords | coordinates, pixel, EPSG:4326 |

## Links

- npm: https://www.npmjs.com/package/coordinates2pixels
- Repository: https://github.com/jfgodoy/coordinates2pixels
- Issues: https://github.com/jfgodoy/coordinates2pixels/issues
- npm.io page: https://npm.io/package/coordinates2pixels

## Recent versions

- 1.0.0 (latest) — 2015-12-23

## README

# Coordinates2pixels
Coordinates2pixels is a utility module which helps to convert from geographic coordinates (EPSG:4326) to pixel coordinates and the other way round.

# Installation

```
npm install --save coordinates2pixels
```

# API

function | description
---|---
`lng2pixel(lng, zoom)` | converts longitude to pixels coordinates (return a float).
`lat2pixel(lat, zoom)` | converts latitude to pixels coordinates (return a float).
`pixel2lng(x, zoom)` | converts x to geographic coordinates.
`pixel2lat(y, zoom)` | converts y to geographic coordinates.

# Usage
see `example/square.js`

```javascript
var coords = require('coordinates2pixels');

// create a square around the coordinates
function square(lng, lat, zoom, size) {
  var px = coords.lng2pixel(lng, zoom),
      py = coords.lat2pixel(lat, zoom);

  var box = [
    coords.pixel2lat(py + size/2, zoom),
    coords.pixel2lng(px - size/2, zoom),
    coords.pixel2lat(py - size/2, zoom),
    coords.pixel2lng(px + size/2, zoom)
  ]

  return box;
}


// create a square of 100x100 pixels around coordinates (-70,-33)
var bbox = square(-70, -33, 18, 100);
// [ -33.00022494868904, -70.00026822090148, -32.99977505073747, -69.9997317790985 ]
```


# License

License: http://jfgodoy.mit-license.org

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