intersect 是一个 Turf 中的 transformation(转换),它接收两个 feature(要素),并返回它们的交集。如果原始要素没有相交的部分,则返回一个空 feature。
| 参数 | 类型 | 描述 | 
|---|---|---|
feature1 | 
GeoJSON Feature 对象 | 
第一个要素 | 
feature2 | 
GeoJSON Feature 对象 | 
第二个要素 | 
GeoJSON Feature 对象 - 两个要素的交集var intersect = require('@turf/intersect');
var polygon1 = turf.polygon([[[0, 0], [0, 10], [10, 10], [10, 0]]]);
var polygon2 = turf.polygon([[[5, 5], [5, 15], [15, 15], [15, 5]]]);
var result = intersect(polygon1, polygon2);
console.log(result);
{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[5, 10], [10, 10], [10, 5], [5, 5], [5, 10]]]
  }
}
intersect 只能计算两个 feature 相交部分的几何形状,它们的属性信息将不会被计算。feature 都必须为多边形,否则将会引发异常。