as_cubble | R Documentation |
Coerce foreign objects into a cubble object
as_cubble(data, key, index, coords, ...)
## S3 method for class 'data.frame'
as_cubble(data, key, index, coords, ...)
## S3 method for class 'tbl_df'
as_cubble(data, key, index, coords, crs, dimensions, ...)
## S3 method for class 'sf'
as_cubble(data, key, index, ...)
## S3 method for class 'ncdf4'
as_cubble(
data,
key,
index,
coords,
vars,
lat_range = NULL,
long_range = NULL,
...
)
## S3 method for class 'stars'
as_cubble(data, key, index, coords, ...)
## S3 method for class 'sftime'
as_cubble(data, key, index, coords, ...)
data |
an object to be converted into an cubble object. Currently
support objects of classes |
key |
a character (symbol), the spatial identifier,
see |
index |
a character (symbol), the temporal identifier,
see |
coords |
a vector of character (symbol) of length 2,
see |
... |
other arguments. |
crs |
used in |
dimensions |
used when creating a cubble from a stars object |
vars |
a vector of variables to read in (with quote),
used in |
lat_range , long_range |
in the syntax of |
a cubble object
climate_flat |> as_cubble(key = id, index = date, coords = c(long, lat))
# only need `coords` if create from a tsibble
dt <- climate_flat |> tsibble::as_tsibble(key = id, index = date)
dt |> as_cubble(coords = c(long, lat))
# netcdf
path <- system.file("ncdf/era5-pressure.nc", package = "cubble")
raw <- ncdf4::nc_open(path)
dt <- as_cubble(raw)
# subset degree
dt <- as_cubble(raw,vars = c("q", "z"),
long_range = seq(113, 153, 3),
lat_range = seq(-53, -12, 3))
## Not run:
# stars - take a few seconds to run
tif <- system.file("tif/L7_ETMs.tif", package = "stars")
x <- stars::read_stars(tif)
x |> as_cubble(index = band)
## End(Not run)
# don't have to supply coords if create from a sftime
dt <- climate_flat |>
sf::st_as_sf(coords = c("long", "lat"), crs = sf::st_crs("OGC:CRS84")) |>
sftime::st_as_sftime()
dt |> as_cubble(key = id, index = date)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.