# geojson-bounds

> Extent, envelope, xMin/Max, and yMin/Max for GeoJSON

Latest version **1.0.4** (published 2024-03-31) · CC-BY-4.0 license · 0 weekly downloads

## Install

```sh
npm install geojson-bounds
pnpm add geojson-bounds
yarn add geojson-bounds
bun add geojson-bounds
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2024-03-31 |
| First published | 2016-02-01 |
| Weekly downloads | 0 |
| License | CC-BY-4.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | John J Czaplewski |
| Maintainers | jczaplew |
| Keywords | geojson, extent, envelope, xmin, xmax, ymin, ymax |

## Links

- npm: https://www.npmjs.com/package/geojson-bounds
- Repository: https://github.com/jczaplew/geojson-bounds
- Issues: https://github.com/jczaplew/geojson-bounds/issues
- npm.io page: https://npm.io/package/geojson-bounds

## Dependencies (1)

- [@types/geojson](https://npm.io/package/@types/geojson.md) ^7946.0.7

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2024-03-31
- 1.0.3 — 2024-03-31
- 1.0.2 — 2019-01-23
- 1.0.1 — 2016-02-02
- 1.0.0 — 2016-02-01

## README

# geojson-bounds
Dependency-free methods for extracting the extent, envelope, minimum latitude, minimum longitude, maximum latitude, and maximum longitude
from a valid GeoJSON representation.

Designed to follow PostGIS's conventions for these operations as much as possible.

## Install
````
npm install geojson-bounds
````

## Example usage
````
var st = require('geojson-bounds');

var shape = { "type": "Polygon",
  "coordinates": [
    [ [100.1, 0.1], [101.0, 0.1], [101.0, 1.0], [100.1, 1.0], [100.1, 0.1] ],
    [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
  ]
}

st.extent(shape)
// => [ 100.1, 0.1, 101, 1 ]

st.envelope(shape)
// => {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[100.1,0.1],[100.1,1],[101,1],[101,0.1],[100.1,0.1]]]}}

st.xMin(shape)
// => 100.1

st.xMax(shape)
// => 101

st.yMin(shape)
// => 0.1

st.yMax(shape)
// => 1
````


## API

### .extent(*geojson*)
Returns an array of coordinates in the order [*West*, *South*, *East*, *North*] that represents the
extent of the provided feature or geometry.


### .envelope(*geojson*)
Returns a GeoJSON `Feature` polygon that repesents the bounding box of the provided feature or geometry.

### .xMin(*geojson*)
Returns the western-most longitude of the provided feature or geometry.

### .xMax(*geojson*)
Returns the eastern-most longitude of the provided feature or geometry.

### .yMin(*geojson*)
Returns the southern-most latitude of the provided feature or geometry.

### .yMax(*geojson*)
Returns the northern-most latitude of the provided feature or geometry.



## Licenese
CC-BY-4.0 for all code unique to this repository

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