lsp_add_examples: Adds spatial data of each region in an lsp or sf object

Description Usage Arguments Value Examples

View source: R/lsp_add_examples.R

Description

Adds spatial data of each region in an lsp or sf object. The output is an lsp or sf object with an additional column "region". See examples.

Usage

1
2
3
4
5
6
7
lsp_add_examples(x, y, window = NULL)

## S3 method for class 'lsp'
lsp_add_examples(x, y, window = NULL)

## S3 method for class 'sf'
lsp_add_examples(x, y, window = NULL)

Arguments

x

Object of class lsp - usually a subset of the output of lsp_signature() or an object of class sf - usually a subset of the output of lsp_search()

y

Object of class stars or stars_proxy.

window

Specifies areas for analysis. It can be either: NULL or an sf object. The sf object is only needed for adding examples of irregular regions.

Value

The input object with a new column "region". The "region" column is a list with a raster extracted for each row.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library(stars)

landcover = read_stars(system.file("raster/landcover2015s.tif", package = "motif"))

landcover_coma = lsp_signature(landcover, type = "coma", threshold = 0.9, window = 100)
selected_coma = subset(landcover_coma, id %in% c(5, 10, 15, 35))
selected_coma

selected_coma = lsp_add_examples(x = selected_coma, y = landcover)
selected_coma

plot(selected_coma$region[[1]])
plot(selected_coma$region[[4]])


# larger data example
library(stars)

landcover = read_stars(system.file("raster/landcover2015.tif", package = "motif"))

landcover_coma = lsp_signature(landcover, type = "coma", threshold = 0.9, window = 100)
selected_coma = subset(landcover_coma, id %in% c(5, 80, 1971, 2048))
selected_coma

selected_coma = lsp_add_examples(x = selected_coma, y = landcover)
selected_coma

plot(selected_coma$region[[1]])
plot(selected_coma$region[[4]])

motif documentation built on June 4, 2021, 1:08 a.m.