lawn_transform_scale: Scale a GeoJSON feature

View source: R/transform_scale.R

lawn_transform_scaleR Documentation

Scale a GeoJSON feature

Description

Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger). If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.

Usage

lawn_transform_scale(
  x,
  factor,
  origin = "centroid",
  mutate = FALSE,
  lint = FALSE
)

Arguments

x

a feature

factor

(integer/numeric) of scaling, positive or negative values greater than 0

origin

(integer/numeric) Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid) (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 scaled data-Feature

Examples

x <- '{
 "type": "Feature",
 "properties": {},
 "geometry": {
   "type": "Polygon",
   "coordinates": [
    [
      [ 0, 29 ], [ 3.5, 29 ], [ 2.5, 32 ], [ 0, 29 ]
    ]
  ]
 }
}'
lawn_transform_scale(x, factor = 3)

lawn_transform_scale(x, factor = 100)
lawn_transform_scale(x, factor = 100, mutate = TRUE)

## Not run: 
view(lawn_featurecollection(x))
view(lawn_featurecollection(
  lawn_transform_scale(x, factor = 2)
))
view(lawn_featurecollection(
  lawn_transform_scale(x, factor = 3)
))
view(lawn_featurecollection(
  lawn_transform_scale(x, factor = 2, origin = "sw")
))
view(lawn_featurecollection(
  lawn_transform_scale(x, factor = 2, origin = "ne")
))

## End(Not run)

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