lawn_transform_translate: Translate a GeoJSON feature

View source: R/transform_translate.R

lawn_transform_translateR Documentation

Translate a GeoJSON feature

Description

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

Usage

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

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)

ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.