Skip to main content
Version: 7.0.0

transformTranslate

Description

Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line on the provided direction angle.

Parameters

NameTypeDescription
geojsonGeoJSONobject to be translated
distancenumberlength of the motion; negative values determine motion in opposite direction
directionnumberof the motion; angle from North in decimal degrees, positive clockwise
options?ObjectOptional parameters (default {})
options.units?stringin which distance will be express; miles, kilometers, degrees, or radians (default 'kilometers')
options.zTranslation?numberlength of the vertical motion, same unit of distance (default 0)
options.mutate?booleanallows GeoJSON input to be mutated (significant performance increase if true) (default false)

Returns

    GeoJSON the translated GeoJSON object

Examples

var poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
var translatedPoly = turf.transformTranslate(poly, 100, 35);

Installation

$ npm install @turf/transform-translate

import { transformTranslate } from "@turf/transform-translate";
const result = transformTranslate(...);
$ npm install @turf/turf

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