difference
描述
🌐 Description
通过从第一个多边形剪切后续多边形,找到多个多边形之间的差异。
🌐 Finds the difference between multiple polygons by clipping the subsequent polygon from the first.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| features | FeatureCollection<Polygon | MultiPolygon> | 输入多边形要素 |
返回
🌐 Returns
Feature<Polygon | MultiPolygon> | null 一个多边形或多多边形要素,显示 polygon1 的区域,不包括 polygon2 的区域(如果为空,则返回 null)
示例
🌐 Examples
var polygon1 = turf.polygon(
[
[
[128, -26],
[141, -26],
[141, -21],
[128, -21],
[128, -26],
],
],
{
fill: "#F00",
"fill-opacity": 0.1,
},
);
var polygon2 = turf.polygon(
[
[
[126, -28],
[140, -28],
[140, -20],
[126, -20],
[126, -28],
],
],
{
fill: "#00F",
"fill-opacity": 0.1,
},
);
var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));
安装
🌐 Installation
$ npm install @turf/difference
import { difference } from "@turf/difference";
const result = difference(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.difference(...);