Creates or adds a sf object based on the input object or a set of parameters. It accepts either an object of class stars or lsp. In the first case, the output is created based on a set of parameters (window_size and window_shift or window). In the second case, the output converts the lsp object into a sf object.

lsp_add_sf(x = NULL, window = NULL, metadata = TRUE)

# S3 method for default
lsp_add_sf(x = NULL, window = NULL, metadata = TRUE)

# S3 method for lsp
lsp_add_sf(x = NULL, window = NULL, metadata = TRUE)

Arguments

x

Object of class stars or lsp. For stars, window or window_size can be used.

window

Specifies areas for analysis. It can be either: NULL, a numeric value, or an sf object. If window=NULL calculations are performed for a whole area. If the window argument is numeric, it is a length of the side of a square-shaped block of cells. Expressed in the numbers of cells, it defines the extent of a local pattern. If an sf object is provided, each feature (row) defines the extent of a local pattern. The sf object should have one attribute (otherwise, the first attribute is used as an id).

metadata

Logical. Only when x`` is of class lsp. If TRUE, the output object will have metadata ("id" and "na_prop"). If FALSE`, the output object will not have metadata ("id" and "na_prop").

Value

An sf object converted from the input object or a provided set of parameters

Examples

library(stars)
landform = read_stars(system.file("raster/landforms.tif", package = "motif"))
plot(landform)

landform_lsp = lsp_add_sf(landform, window = 100)
plot(landform_lsp)


lc_cove = lsp_signature(landform, type = "cove", window = 200, normalization = "pdf")
lc_cove_lsp = lsp_add_sf(lc_cove)
plot(lc_cove_lsp["id"])

plot(lc_cove_lsp["na_prop"])


# \donttest{
# larger data example
library(stars)
landform = read_stars(system.file("raster/landform.tif", package = "motif"))
plot(landform)
#> downsample set to 10
#> Error in image.stars(x, ..., axes = axes, breaks = breaks, col = col,     key.pos = key.pos, key.width = key.width, key.length = key.length,     main = NULL): rgb plotting not supported on this device
landform_lsp = lsp_add_sf(landform, window = 100)
plot(landform_lsp)



lc_cove = lsp_signature(landform, type = "cove", window = 200, normalization = "pdf")
lc_cove_lsp = lsp_add_sf(lc_cove)
plot(lc_cove_lsp["id"])

plot(lc_cove_lsp["na_prop"])

# }