transformRotate
Description
Rotates any geojson Feature or Geometry of a specified angle, around its centroid
or a given pivot
point.
Parameters
Name | Type | Description |
---|---|---|
geojson | GeoJSON | object to be rotated |
angle | number | of rotation in decimal degrees, positive clockwise |
options? | Object | Optional parameters (default {}) |
options.pivot? | Coord | point around which the rotation will be performed (default 'centroid') |
options.mutate? | boolean | allows GeoJSON input to be mutated (significant performance increase if true) (default false) |
Returns
GeoJSON the rotated GeoJSON feature
Examples
const poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
const options = { pivot: [0, 25] };
const rotatedPoly = turf.transformRotate(poly, 10, options);
Installation
$ npm install @turf/transform-rotate
import { transformRotate } from "@turf/transform-rotate";
const result = transformRotate(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.transformRotate(...);