Atlaslog
Atlaslog / Turf.js / API / flatten
Turf.js · API reference

flatten

Quick answer

Flattens any GeoJSON to a FeatureCollection inspired by geojson-flatten.

Last verified 2026-11-03 · Turf.js 7.x · Cite this page
Runnable examplesChinese noteAll API topics

Description​

Flattens any GeoJSON to a FeatureCollection inspired by geojson-flatten.

Parameters​

NameTypeDescription
geojsonGeoJSONany valid GeoJSON Object

Returns​

FeatureCollection<any> all Multi-Geometries are flattened into single Features

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(...);
TutorialsAPI index
English reference text adapted from the official Turf.js documentation, © Turf.js contributors, licensed under MIT.
Original page: https://turfjs.org/docs/api/flatten · Chinese note: /turf/api/flatten.html
Cite this page

Atlaslog (2026). flatten. https://www.jingweizhi.com/en/turf/api/flatten.html (accessed 2026-11-03).