# turf-intersect

> find the intersection of spatial features

Latest version **3.0.12** (published 2016-07-05) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install turf-intersect
pnpm add turf-intersect
yarn add turf-intersect
bun add turf-intersect
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.12 |
| Published | 2016-07-05 |
| First published | 2014-05-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Morgan Herlocker |
| Maintainers | cspanring, cwmma, jseppi, jvrousseau, lyzidiamond, morganherlocker, mourner, tcql, tmcw |
| Keywords | turf, gis, intersect |

## Links

- npm: https://www.npmjs.com/package/turf-intersect
- Repository: https://github.com/Turfjs/turf-intersect
- Issues: https://github.com/Turfjs/turf-intersect/issues
- npm.io page: https://npm.io/package/turf-intersect

## Dependencies (1)

- [jsts](https://npm.io/package/jsts.md) 1.1.2

## Recent versions

- 3.0.12 (latest) — 2016-07-05
- 3.0.7-canary.ae89c8b3 (canary) — 2016-06-14
- 3.0.10 — 2016-06-15
- 3.0.1 — 2016-05-16
- 3.0.0-canary.7879bf6c — 2016-05-16
- 3.0.0-canary.2f5f7167 — 2016-05-16
- 1.4.2 — 2015-03-24
- 1.4.1 — 2015-02-06
- 1.4.0 — 2015-02-06
- 1.3.2 — 2014-12-18
- 1.3.1 — 2014-12-11
- 1.3.0 — 2014-11-26
- 1.2.0 — 2014-11-07
- 1.1.0 — 2014-11-07
- 1.0.2 — 2014-10-31
- … 3 more at https://npm.io/package/turf-intersect/versions

## README

# turf-intersect

# intersect

Takes two [polygons](Polygon) and finds their intersection. If they share a border, returns the border; if they don't intersect, returns undefined.

**Parameters**

-   `poly1` **Feature&lt;Polygon>** the first polygon
-   `poly2` **Feature&lt;Polygon>** the second polygon

**Examples**

```javascript
var poly1 = {
  "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-122.801742, 45.48565],
      [-122.801742, 45.60491],
      [-122.584762, 45.60491],
      [-122.584762, 45.48565],
      [-122.801742, 45.48565]
    ]]
  }
}
var poly2 = {
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-122.520217, 45.535693],
      [-122.64038, 45.553967],
      [-122.720031, 45.526554],
      [-122.669906, 45.507309],
      [-122.723464, 45.446643],
      [-122.532577, 45.408574],
      [-122.487258, 45.477466],
      [-122.520217, 45.535693]
    ]]
  }
}

var polygons = {
  "type": "FeatureCollection",
  "features": [poly1, poly2]
};

var intersection = turf.intersect(poly1, poly2);

//=polygons

//=intersection
```

Returns **(Feature&lt;Polygon> | [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) | Feature&lt;MultiLineString>)** if `poly1` and `poly2` overlap, returns a Polygon feature representing the area they overlap; if `poly1` and `poly2` do not overlap, returns `undefined`; if `poly1` and `poly2` share a border, a MultiLineString of the locations where their borders are shared

---

This module is part of the [Turfjs project](http://turfjs.org/), an open source
module collection dedicated to geographic algorithms. It is maintained in the
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
PRs and issues.

### Installation

Install this module individually:

```sh
$ npm install turf-intersect
```

Or install the Turf module that includes it as a function:

```sh
$ npm install turf
```

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