Rotates a geometry around its center or a given point.
npm install @turf/transform-rotateRotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point.
* geojson [GeoJSON][1] object to be rotated
* angle [number][2] of rotation in decimal degrees, positive clockwise
* options [Object][3] Optional parameters (optional, default {})
* options.pivot [Coord][4] point around which the rotation will be performed (optional, default 'centroid')
* options.mutate [boolean][5] allows GeoJSON input to be mutated (significant performance increase if true) (optional, default false)
``javascript
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);
//addToMap
const addToMap = [poly, rotatedPoly];
rotatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
`
Returns [GeoJSON][1] the rotated GeoJSON feature
[1]: https://tools.ietf.org/html/rfc7946#section-3
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.1
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
---
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.
Install this single module individually:
`sh`
$ npm install @turf/transform-rotate
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf