Appearance
函数: mask()
mask<
T>(polygon:T|Feature<T,GeoJsonProperties> |FeatureCollection<T,GeoJsonProperties>,mask?:Polygon|Feature<Polygon,GeoJsonProperties>,options?: {mutate?:boolean; }):Feature<Polygon>
Function
Takes polygons or multipolygons and an optional mask, and returns an exterior ring polygon with holes.
类型参数
T
T extends Polygon | MultiPolygon
参数
polygon
GeoJSON polygon used as interior rings or holes
T | Feature<T, GeoJsonProperties> | FeatureCollection<T, GeoJsonProperties>
mask?
GeoJSON polygon used as the exterior ring (if undefined, the world extent is used)
Polygon | Feature<Polygon, GeoJsonProperties>
options?
Optional parameters
mutate?
boolean
allows the mask GeoJSON input to be mutated (performance improvement if true)
返回
Masked Polygon (exterior ring with holes)
示例
ts
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);
//addToMap
const addToMap = [masked]