https://github.com/stepankuzmin/turf-deintersect
Delete GeoJSON polygon intersections
https://github.com/stepankuzmin/turf-deintersect
intersection javascript polygon turfjs
Last synced: 9 months ago
JSON representation
Delete GeoJSON polygon intersections
- Host: GitHub
- URL: https://github.com/stepankuzmin/turf-deintersect
- Owner: stepankuzmin
- Created: 2017-01-09T12:56:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T02:31:45.000Z (over 2 years ago)
- Last Synced: 2025-03-14T03:43:18.163Z (10 months ago)
- Topics: intersection, javascript, polygon, turfjs
- Language: JavaScript
- Size: 777 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# turf-deintersect
[](http://travis-ci.org/stepankuzmin/turf-deintersect)
Delete GeoJSON polygon intersections
### `turf.deintersect(polygons)`
Delete Polygon|polygons intersections by clipping from next polygon
each previous polygon.
### Parameters
| parameter | type | description |
| ---------- | ------------------ | ---------------------- |
| `polygons` | Array\.\ | input polygon features |
### Example
```js
var poly1 = {
"type": "Feature",
"properties": {
"fill": "#0f0"
},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-46.738586, -23.596711],
[-46.738586, -23.458207],
[-46.560058, -23.458207],
[-46.560058, -23.596711],
[-46.738586, -23.596711]
]]
}
};
var poly2 = {
"type": "Feature",
"properties": {
"fill": "#00f"
},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-46.650009, -23.631314],
[-46.650009, -23.5237],
[-46.509246, -23.5237],
[-46.509246, -23.631314],
[-46.650009, -23.631314]
]]
}
};
var deintersected = turf.deintersect([poly1, poly2]);
var polygonsBefore = {
"type": "FeatureCollection",
"features": [poly1, poly2]
};
var polygonsAfter = {
"type": "FeatureCollection",
"features": deintersected
};
//=polygonsBefore
//=polygonsAfter
```
**Returns** `Array.`, a polygon features without intersections
## Installation
Requires [nodejs](http://nodejs.org/).
```sh
$ npm install turf-deintersect
```
## Tests
```sh
$ npm test
```