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 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 2023-09-01 10:23:38.862834 to 2023-09-01 10:23:42.862834.
#>   a                time    geometry
#> 1 1 2023-09-01 10:23:38 POINT (1 2)
#> 2 2 2023-09-01 10:23:39 POINT (1 3)
#> 3 3 2023-09-01 10:23:40 POINT (2 3)
#> 4 4 2023-09-01 10:23:41 POINT (2 1)
#> 5 5 2023-09-01 10:23:42 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 2023-09-01 10:23:38.862834 to 2023-09-01 10:23:42.862834.
#>   a                time    geometry
#> 1 5 2023-09-01 10:23:38 POINT (1 2)
#> 2 4 2023-09-01 10:23:39 POINT (1 3)
#> 3 3 2023-09-01 10:23:40 POINT (2 3)
#> 4 2 2023-09-01 10:23:41 POINT (2 1)
#> 5 1 2023-09-01 10:23:42 POINT (3 1)