Learn R Programming

lawn (version 0.6.0)

lawn_transform_scale: 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

Run this code
# NOT RUN {
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")
))
# }

Run the code above in your browser using DataLab