lawn_transform_translate: Translate a GeoJSON feature

Description Usage Arguments Value Examples

View source: R/transform_translate.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
lawn_transform_translate(
  x,
  distance,
  direction,
  units = "kilometers",
  zTranslation = 0,
  mutate = FALSE,
  lint = FALSE
)

Arguments

x

a feature

distance

(integer/numeric) length of the motion; negative values determine motion in opposite direction

direction

(integer/numeric) of the motion; angle from North in decimal degrees, positive clockwise

units

(character) in which distance will be express; miles, kilometers, degrees, or radians (optional, default kilometers)

zTranslation

(integer/numeric) length of the vertical motion, same unit of distance (optional, default 0)

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 changed data-Feature

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
32
33
34
35
36
37
x <- '{
 "type": "Feature",
 "properties": {},
 "geometry": {
   "type": "Polygon",
   "coordinates": [
    [
      [ 0, 29 ], [ 3.5, 29 ], [ 2.5, 32 ], [ 0, 29 ]
    ]
  ]
 }
}'
lawn_transform_translate(x, distance = 100, direction = 35)

lawn_transform_translate(x, distance = 100, direction = 24)
lawn_transform_translate(x, distance = 100, direction = 24, mutate = TRUE)

## Not run: 
view(lawn_featurecollection(x))
view(lawn_featurecollection(
  lawn_transform_translate(x, distance = 130, direction = 35,
   units = "kilometers")
))
view(lawn_featurecollection(
  lawn_transform_translate(x, distance = 130, direction = -35,
   units = "kilometers")
))
view(lawn_featurecollection(
  lawn_transform_translate(x, distance = 130, direction = 35,
   units = "kilometers", zTranslation = 10)
))
view(lawn_featurecollection(
  lawn_transform_translate(x, distance = 130, direction = 35,
   units = "kilometers", mutate = TRUE)
))

## End(Not run)

Example output

<Feature>
  Type: Polygon
  Bounding box: 0.6 29.7 4.1 32.7
  No. points: 8
  Properties: NULL
<Feature>
  Type: Polygon
  Bounding box: 0.4 29.8 3.9 32.8
  No. points: 8
  Properties: NULL
<Feature>
  Type: Polygon
  Bounding box: 0.4 29.8 3.9 32.8
  No. points: 8
  Properties: NULL

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