transport_sf: Transport (shift, rotate and scale) an sf object

Description Usage Arguments Value Examples

View source: R/shift_map.R

Description

Takes an sf object and a reference sf object and transports it by scaling, shifting it and rotating it.

Usage

1
transport_sf(sf, ref = sf, scale = 1, shift = c(0, 0), rotate = 0)

Arguments

sf

The sf object to transport

ref

The reference sf object

scale

A scaling factor (defaults to 1, meaning no change in scale)

shift

Distance to shift (TKTKTK what units is it?)

rotate

Radians to rotate the sf object

Value

An sf object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Transports Puerto Rico off the coast of Georgia, rotate 90 degrees
# made 4 times bigger (original Puerto Rico in red, moved in blue)
library(ggplot2)
ggplot()+
geom_sf(data=ggcart:::lower48)+
  geom_sf(data=ggcart:::puerto_rico) +
  geom_sf(data=ggcart:::puerto_rico, color = "red")+
  geom_sf(data=transport_sf(sf=ggcart:::puerto_rico,
                       scale=4,
                       shift = c(-130,90)*10000,
                       rotate=pi/2), color="blue")

hlendway/albersextra documentation built on May 17, 2019, 4:21 a.m.