Converts a list-column with signatures into many numeric columns

lsp_restructure(x)

Arguments

x
  • an lsp object

Value

Object of class lsp. It has several columns: (1) id - an id of each window. For irregular windows, it is the values provided in the window argument, (2) na_prop - share (0-1) of NA cells for each window, (3) one or more columns representing values of the signature

Examples


library(stars)

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

landcover_cove = lsp_signature(landcover, type = "cove", threshold = 0.9, window = 100)
landcover_cover = lsp_restructure(landcover_cove)
landcover_cover
#> # A tibble: 47 × 30
#>       id na_prop       X1       X2    X3       X4       X5     X6    X7       X8
#>  * <int>   <dbl>    <dbl>    <dbl> <dbl>    <dbl>    <dbl>  <dbl> <dbl>    <dbl>
#>  1     1    0    0.000303 0.00136  0.998 0        0        0          0 0       
#>  2     2    0    0        0.000758 0.999 0        0        0          0 0       
#>  3     3    0    0.0216   0.0209   0.957 0.000152 0.000455 0          0 0       
#>  4     4    0    0.0610   0.0319   0.906 0        0        0          0 0       
#>  5     5    0    0.123    0.0597   0.816 0        0        0          0 0       
#>  6     6    0    0.126    0.0574   0.804 0        0        0          0 0.000707
#>  7     7    0.32 0.0375   0.0255   0.934 0        0        0          0 0       
#>  8     8    0    0.0122   0.00636  0.729 0.00646  0.0731   0.0877     0 0       
#>  9     9    0    0.0185   0.0142   0.886 0.00157  0.0309   0.0337     0 0       
#> 10    10    0    0.000707 0.00111  0.922 0.000505 0.0316   0.0413     0 0       
#> # ℹ 37 more rows
#> # ℹ 20 more variables: X9 <dbl>, X10 <dbl>, X11 <dbl>, X12 <dbl>, X13 <dbl>,
#> #   X14 <dbl>, X15 <dbl>, X16 <dbl>, X17 <dbl>, X18 <dbl>, X19 <dbl>,
#> #   X20 <dbl>, X21 <dbl>, X22 <dbl>, X23 <dbl>, X24 <dbl>, X25 <dbl>,
#> #   X26 <dbl>, X27 <dbl>, X28 <dbl>

lsp_add_sf(landcover_cover)
#> Simple feature collection with 47 features and 30 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -400176.1 ymin: -609756.5 xmax: -190176.1 ymax: -399756.5
#> Projected CRS: unnamed
#> # A tibble: 47 × 31
#>       id na_prop       X1       X2    X3       X4       X5     X6    X7       X8
#>    <int>   <dbl>    <dbl>    <dbl> <dbl>    <dbl>    <dbl>  <dbl> <dbl>    <dbl>
#>  1     1    0    0.000303 0.00136  0.998 0        0        0          0 0       
#>  2     2    0    0        0.000758 0.999 0        0        0          0 0       
#>  3     3    0    0.0216   0.0209   0.957 0.000152 0.000455 0          0 0       
#>  4     4    0    0.0610   0.0319   0.906 0        0        0          0 0       
#>  5     5    0    0.123    0.0597   0.816 0        0        0          0 0       
#>  6     6    0    0.126    0.0574   0.804 0        0        0          0 0.000707
#>  7     7    0.32 0.0375   0.0255   0.934 0        0        0          0 0       
#>  8     8    0    0.0122   0.00636  0.729 0.00646  0.0731   0.0877     0 0       
#>  9     9    0    0.0185   0.0142   0.886 0.00157  0.0309   0.0337     0 0       
#> 10    10    0    0.000707 0.00111  0.922 0.000505 0.0316   0.0413     0 0       
#> # ℹ 37 more rows
#> # ℹ 21 more variables: X9 <dbl>, X10 <dbl>, X11 <dbl>, X12 <dbl>, X13 <dbl>,
#> #   X14 <dbl>, X15 <dbl>, X16 <dbl>, X17 <dbl>, X18 <dbl>, X19 <dbl>,
#> #   X20 <dbl>, X21 <dbl>, X22 <dbl>, X23 <dbl>, X24 <dbl>, X25 <dbl>,
#> #   X26 <dbl>, X27 <dbl>, X28 <dbl>, geometry <POLYGON [m]>