New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@turf/simplify

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/simplify

turf simplify module


Version published
Weekly downloads
1.2M
increased by11.92%
Maintainers
4
Weekly downloads
 
Created

What is @turf/simplify?

@turf/simplify is a module within the Turf.js library that provides functionality to simplify GeoJSON geometries. It uses the Ramer-Douglas-Peucker algorithm to reduce the number of points in a geometry while retaining its overall shape. This can be useful for reducing the complexity of geometries for faster processing and rendering.

What are @turf/simplify's main functionalities?

Simplify a LineString

This feature allows you to simplify a LineString geometry. The `tolerance` parameter controls the level of simplification, and `highQuality` determines whether to use a slower, higher-quality algorithm.

const turf = require('@turf/turf');
const line = turf.lineString([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]);
const simplified = turf.simplify(line, {tolerance: 0.01, highQuality: false});
console.log(simplified);

Simplify a Polygon

This feature allows you to simplify a Polygon geometry. Similar to the LineString example, you can control the simplification level with the `tolerance` parameter and choose between a faster or higher-quality algorithm with `highQuality`.

const turf = require('@turf/turf');
const polygon = turf.polygon([[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 0]]]);
const simplified = turf.simplify(polygon, {tolerance: 0.01, highQuality: false});
console.log(simplified);

Other packages similar to @turf/simplify

FAQs

Package last updated on 06 Jun 2017

Did you know?

Socket

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.

Install

Related posts