Skip to contents

Convert other R objects into s2cd vectors

Usage

as_s2cd(x, ...)

Arguments

x

an object to convert

...

passed to methods; for the data.frame method, passed to s2cd()

Methods implemented for

  • data.frame: must have column "s2_cell" and list-column "dates"

  • s2cd: returned as-is

Examples

data.frame(
     s2_cell = s2::as_s2_cell(c("8841b39a7c46e25f", "8841a45555555555")),
     dates = I(list(
       as.Date("2026-01-01"),
       c(as.Date("2024-09-13"), as.Date("2024-09-20"))
     ))
   ) |>
  as_s2cd()
#> <s2_cell_dates[2]>
#> [1] 8841b39a7c46e25f[1] 8841a45555555555[2]

as_s2cd(s2cd_example())
#> <s2_cell_dates[2]>
#> [1] 8841b39a7c46e25f[1] 8841a45555555555[2]