lawn_transform_rotate: Rotate a GeoJSON feature

Description Usage Arguments Value Note Examples

View source: R/transform_rotate.R

Description

Rotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point

Usage

1
lawn_transform_rotate(x, angle, pivot = c(0, 0), mutate = FALSE, lint = FALSE)

Arguments

x

a feature

angle

(integer/numeric) number of rotation (along the vertical axis), from North in decimal degrees, negative clockwise

pivot

(integer/numeric) point around which the rotation will be performed (optional, default centroid)

mutate

(logical) allows GeoJSON input to be mutated (significant performance increase if true) (optional). Default: FALSE

lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

a rotated data-Feature

Note

all rotations follow the right-hand rule

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
x <- '{
 "type": "Feature",
 "properties": {},
 "geometry": {
   "type": "Polygon",
   "coordinates": [
    [
      [ 0, 29 ], [ 3.5, 29 ], [ 2.5, 32 ], [ 0, 29 ]
    ]
  ]
 }
}'
lawn_transform_rotate(x, angle = 100, pivot = c(15, 15))

lawn_transform_rotate(x, angle = 100)
lawn_transform_rotate(x, angle = 100, mutate = TRUE)

## Not run: 
view(lawn_featurecollection(x))
view(lawn_featurecollection(lawn_transform_rotate(x, angle = 100)))
view(lawn_featurecollection(
  lawn_transform_rotate(x, angle = 100, pivot = c(15, 15))
))
view(lawn_featurecollection(
  lawn_transform_rotate(x, angle = 150, pivot = c(15, 15))
))
view(lawn_featurecollection(
  lawn_transform_rotate(x, angle = 300, pivot = c(0, 4))
))

## End(Not run)

lawn documentation built on Jan. 6, 2021, 5:07 p.m.