transformTranslate
Description
Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line on the provided direction angle.
Note that this moves the points of your shape individually and can therefore change the overall shape. How noticable this is depends on the distance and the used projection.
Parameters
Name | Type | Description |
---|---|---|
geojson | GeoJSON | GeometryCollection | object to be translated |
distance | number | length of the motion; negative values determine motion in opposite direction |
direction | number | of the motion; angle from North in decimal degrees, positive clockwise |
options? | Object | Optional parameters (default {}) |
options.units? | Units | in which distance will be express; miles, kilometers, degrees, or radians (default 'kilometers') |
options.zTranslation? | number | length of the vertical motion, same unit of distance (default 0) |
options.mutate? | boolean | allows GeoJSON input to be mutated (significant performance increase if true) (default false) |
Returns
GeoJSON | GeometryCollection 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(...);