Skip to main content
Version: 7.3.0

mask

描述

🌐 Description

接收多边形或多多边形以及可选的掩膜,并返回带孔的外环多边形。

🌐 Takes polygons or multipolygons and an optional mask, and returns an exterior ring polygon with holes.

参数

🌐 Parameters

名称类型描述
polygonPolygon | MultiPolygon | Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon>作为内部环或空洞使用的 GeoJSON 多边形
mask?Polygon | Feature<Polygon>GeoJSON 多边形用于外环(如果未定义,则使用世界范围)
options?Object可选参数 (默认 {})
options.mutate?boolean允许对 mask GeoJSON 输入进行修改(如果为真则性能提升)(默认 false)

返回

🌐 Returns

Feature<Polygon> 带孔的多边形(外环带孔)

示例

🌐 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(...);