flatten
描述
🌐 Description
将任何 GeoJSON 扁平化为一个 FeatureCollection,灵感来自 geojson-flatten。
🌐 Flattens any GeoJSON to a FeatureCollection inspired by geojson-flatten.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | 任何有效的 GeoJSON 对象 |
返回
🌐 Returns
FeatureCollection<any> 所有多几何体都被平铺为单一要素
示例
🌐 Examples
var multiGeometry = turf.multiPolygon([
[
[
[102.0, 2.0],
[103.0, 2.0],
[103.0, 3.0],
[102.0, 3.0],
[102.0, 2.0],
],
],
[
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0],
],
[
[100.2, 0.2],
[100.8, 0.2],
[100.8, 0.8],
[100.2, 0.8],
[100.2, 0.2],
],
],
]);
var flatten = turf.flatten(multiGeometry);
安装
🌐 Installation
$ npm install @turf/flatten
import { flatten } from "@turf/flatten";
const result = flatten(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.flatten(...);