🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@turf/truncate

Package Overview
Dependencies
Maintainers
9
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/truncate

Truncates precision of GeoJSON coordinates.

latest
Source
npmnpm
Version
7.3.5
Version published
Weekly downloads
1.1M
-24.93%
Maintainers
9
Weekly downloads
 
Created
Source

@turf/truncate

truncate

Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.

Parameters

  • geojson GeoJSON any GeoJSON Feature, FeatureCollection, Geometry or GeometryCollection.

  • options Object Optional parameters (optional, default {})

    • options.precision number coordinate decimal precision (optional, default 6)
    • options.coordinates number maximum number of coordinates (primarly used to remove z coordinates) (optional, default 3)
    • options.mutate boolean allows GeoJSON input to be mutated (significant performance increase if true) (optional, default false)

Examples

var point = turf.point([
    70.46923055566859,
    58.11088890802906,
    1508
]);
var options = {precision: 3, coordinates: 2};
var truncated = turf.truncate(point, options);
//=truncated.geometry.coordinates => [70.469, 58.111]

//addToMap
var addToMap = [truncated];

Returns GeoJSON layer with truncated 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.

Installation

Install this single module individually:

$ npm install @turf/truncate

Or install the all-encompassing @turf/turf module that includes all modules as functions:

$ npm install @turf/turf

Keywords

turf

FAQs

Package last updated on 19 Apr 2026

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