
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@turf/clean-coords
Advanced tools
@turf/clean-coords is a module from the Turf.js library that is used to clean coordinates in GeoJSON data. It removes redundant coordinates, such as consecutive duplicate points, and ensures the data is optimized for further processing or visualization.
Remove Redundant Coordinates
This feature removes consecutive duplicate coordinates from a GeoJSON LineString. The input line has redundant points which are removed in the cleaned output.
const turf = require('@turf/turf');
const line = turf.lineString([
[0, 0], [1, 1], [1, 1], [2, 2], [3, 3], [3, 3], [4, 4]
]);
const cleaned = turf.cleanCoords(line);
console.log(cleaned);
Clean Polygon Coordinates
This feature cleans redundant coordinates from a GeoJSON Polygon. The input polygon has duplicate points which are removed in the cleaned output.
const turf = require('@turf/turf');
const polygon = turf.polygon([
[
[0, 0], [1, 1], [1, 1], [1, 0], [0, 0], [0, 0]
]
]);
const cleaned = turf.cleanCoords(polygon);
console.log(cleaned);
The simplify-geojson package is used to simplify GeoJSON data by reducing the number of points in geometries while preserving the overall shape. Unlike @turf/clean-coords, which focuses on removing redundant points, simplify-geojson reduces the complexity of the geometry.
The geojson-rewind package ensures that GeoJSON polygons have the correct winding order. While @turf/clean-coords removes redundant coordinates, geojson-rewind focuses on correcting the order of coordinates to ensure they follow the right-hand rule.
Removes redundant coordinates from any GeoJSON Geometry.
options
Object Optional parameters (optional, default {}
)
options.mutate
boolean allows GeoJSON input to be mutated (optional, default false
)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]]
Returns (Geometry | Feature) the cleaned input Feature/Geometry
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this single module individually:
$ npm install @turf/clean-coords
Or install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf
FAQs
turf clean-coords module
The npm package @turf/clean-coords receives a total of 664,741 weekly downloads. As such, @turf/clean-coords popularity was classified as popular.
We found that @turf/clean-coords demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.