Skip to contents

Can be used to create or modify attribute variables; for transforming geometries see st_transform, and all other functions starting with st_.

Usage

# S3 method for class 'sftime'
transform(`_data`, ...)

Arguments

_data

An object of class sftime.

...

Further arguments of the form new_variable=expression

Value

_data (an sftime object) with modified attribute values (columns).

Examples

# create an sftime object
g <- st_sfc(st_point(c(1, 2)), st_point(c(1, 3)), st_point(c(2, 3)), 
     st_point(c(2, 1)), st_point(c(3, 1)))
x <- 
   data.frame(a = 1:5, g, time = Sys.time() + 1:5, stringsAsFactors = FALSE)
x_sftime <- st_as_sftime(x)
x_sftime
#> Spatiotemporal feature collection with 5 features and 1 field
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 1 ymin: 1 xmax: 3 ymax: 3
#> CRS:           NA
#> Time column with classes: 'POSIXct', 'POSIXt'.
#> Ranging from 2024-09-13 09:15:24.003685 to 2024-09-13 09:15:28.003685.
#>   a                time    geometry
#> 1 1 2024-09-13 09:15:24 POINT (1 2)
#> 2 2 2024-09-13 09:15:25 POINT (1 3)
#> 3 3 2024-09-13 09:15:26 POINT (2 3)
#> 4 4 2024-09-13 09:15:27 POINT (2 1)
#> 5 5 2024-09-13 09:15:28 POINT (3 1)

# modify values in column a
transform(x_sftime, a = rev(a))
#> Spatiotemporal feature collection with 5 features and 1 field
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 1 ymin: 1 xmax: 3 ymax: 3
#> CRS:           NA
#> Time column with classes: 'POSIXct', 'POSIXt'.
#> Ranging from 2024-09-13 09:15:24.003685 to 2024-09-13 09:15:28.003685.
#>   a                time    geometry
#> 1 5 2024-09-13 09:15:24 POINT (1 2)
#> 2 4 2024-09-13 09:15:25 POINT (1 3)
#> 3 3 2024-09-13 09:15:26 POINT (2 3)
#> 4 2 2024-09-13 09:15:27 POINT (2 1)
#> 5 1 2024-09-13 09:15:28 POINT (3 1)