turf.js 计算difference面差

turf.js difference计算面差

在这里插入图片描述
Finds the difference between two polygons by clipping the second polygon from the first.

如图示计算的是属于面1不属于面2的部分;千万不要理解错了。

Arguments参数

ArgumentTypeDescription
polygon1Feature <(Polygon、MultiPolygon)>input Polygon feature
polygon2Feature <(Polygon、MultiPolygon)>Polygon feature to difference from polygon1

翻译如下

参数类型描述
面1特征对象 <(面、多面)>输入面
面2特征对象 <(面、多面)>相对于面1用于做差的面2

Returns返回值
(Feature <(Polygon|MultiPolygon)>|null) - a Polygon or MultiPolygon feature showing the area of polygon1 excluding the area of polygon2 (if empty returns null )

一个Polygon或MultiPolygon要素,显示了polygon1的面积,不包括polygon2的面积(如果empty返回null)
Example例子

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(polygon1, polygon2);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值