Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/transform-translate

Package Overview
Dependencies
Maintainers
9
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/transform-translate

turf transform-translate module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
822K
increased by20.16%
Maintainers
9
Weekly downloads
 
Created

What is @turf/transform-translate?

@turf/transform-translate is a module from the Turf.js library that allows you to translate GeoJSON features by a specified distance along a given direction. This can be useful for tasks such as moving geometries, creating buffers, or simulating movement.

What are @turf/transform-translate's main functionalities?

Translate a Point

This feature allows you to translate a point by a specified distance and direction. In this example, a point is translated 100 meters at a 45-degree angle.

const turf = require('@turf/turf');

const point = turf.point([-75.343, 39.984]);
const translatedPoint = turf.transformTranslate(point, 100, 45);
console.log(translatedPoint);

Translate a Polygon

This feature allows you to translate a polygon by a specified distance and direction. In this example, a polygon is translated 200 meters at a 90-degree angle.

const turf = require('@turf/turf');

const polygon = turf.polygon([[
  [-75.343, 39.984],
  [-75.534, 39.123],
  [-75.123, 39.123],
  [-75.343, 39.984]
]]);
const translatedPolygon = turf.transformTranslate(polygon, 200, 90);
console.log(translatedPolygon);

Translate a LineString

This feature allows you to translate a LineString by a specified distance and direction. In this example, a LineString is translated 50 meters at a 180-degree angle.

const turf = require('@turf/turf');

const line = turf.lineString([[-75.343, 39.984], [-75.534, 39.123]]);
const translatedLine = turf.transformTranslate(line, 50, 180);
console.log(translatedLine);

Other packages similar to @turf/transform-translate

Keywords

FAQs

Package last updated on 09 Aug 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc