mask
描述
🌐 Description
接收多边形或多多边形以及可选的掩膜,并返回带孔的外环多边形。
🌐 Takes polygons or multipolygons and an optional mask, and returns an exterior ring polygon with holes.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| polygon | Polygon | MultiPolygon | Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon> | 作为内部环或空洞使用的 GeoJSON 多边形 |
| mask? | Polygon | Feature<Polygon> | GeoJSON 多边形用于外环(如果未定义,则使用世界范围) |
| options? | Object | 可选参数 (默认 {}) |
| options.mutate? | boolean | 允许对 mask GeoJSON 输入进行修改(如果为真则性能提升)(默认 false) |
返回
🌐 Returns
示例
🌐 Examples
const polygon = turf.polygon([
[
[112, -21],
[116, -36],
[146, -39],
[153, -24],
[133, -10],
[112, -21],
],
]);
const mask = turf.polygon([
[
[90, -55],
[170, -55],
[170, 10],
[90, 10],
[90, -55],
],
]);
const masked = turf.mask(polygon, mask);
安装
🌐 Installation
$ npm install @turf/mask
import { mask } from "@turf/mask";
const result = mask(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.mask(...);