Skip to main content
Version: 7.1.0

cleanCoords

Description

Removes redundant coordinates from any GeoJSON Geometry.

Parameters

NameTypeDescription
geojsonGeometry | FeatureFeature or Geometry
options?ObjectOptional parameters (default {})
options.mutate?booleanallows GeoJSON input to be mutated (default false)

Returns

Examples

var line = turf.lineString([
[0, 0],
[0, 2],
[0, 5],
[0, 8],
[0, 8],
[0, 10],
]);
var multiPoint = turf.multiPoint([
[0, 0],
[0, 0],
[2, 2],
]);

turf.cleanCoords(line).geometry.coordinates;
//= [[0, 0], [0, 10]]

turf.cleanCoords(multiPoint).geometry.coordinates;
//= [[0, 0], [2, 2]]

Installation

$ npm install @turf/clean-coords

import { cleanCoords } from "@turf/clean-coords";
const result = cleanCoords(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.cleanCoords(...);