extract: Extract or replace parts of a 'rasterly' object

Description Usage Arguments Details Examples

Description

The extract function provides functionality for updating existing rasterly objects.

Usage

1
2
3
4
5
## S3 method for class 'rasterly'
x[name]

## S3 replacement method for class 'rasterly'
x[name, ...] <- value

Arguments

x

Object from which to extract element(s) or in which to replace element(s).

name

Character. A literal string to be extracted from x. See details for more information.

...

(missing) or NULL.

value

values to replace; typically an array-like R object of a similar class as x.

Details

Available names:

Set level in .... level is numeric used for specifing level of 'rasterly' object to modify; default is 1 for the parent layer (rasterly()).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(rasterly)
r <- rasterly(
       data = data.frame(x = 1:1e4, y = runif(1e4), category = sample(1:4, 1e4, replace = TRUE)),
       mapping = aes(x = x, y = y)
) %>%
  rasterly_points(xlim = c(1, 5000)) %>%
  rasterly_points(
    mapping = aes(x = x, y = y, color = category),
    xlim = c(5001, 1e4)
  )
r["mapping"]
r["xlim"]

# reassign parent `rasterly()` mapping
r["mapping"] <- aes(x = x, y = y, color = category)
r["mapping"]

# reassign all mapping systems
r["mapping", level = 1:length(r)] <- aes(x = x, y = y)
r["mapping"]

rasterly documentation built on July 2, 2020, 2:12 a.m.