Cross joins match each row in x to every row in y.
See dplyr::cross_join() for details.
Usage
# S3 method for class 'SpatVector'
cross_join(x, y, ..., copy = FALSE, suffix = c(".x", ".y"))Arguments
- x
A
SpatVectorcreated withterra::vect().- y
A data frame or other object coercible to a data frame. If a
SpatVectororsfobject is provided, this method returns an error.- ...
Additional arguments passed on to
sf::st_as_sf().- copy
If
xandyare not from the same data source, andcopyisTRUE, thenywill be copied into the same src asx. This allows you to join tables across srcs, but it is a potentially expensive operation so you must opt into it.- suffix
If there are non-joined duplicate variables in
xandy, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.
Methods
Implementation of the generic dplyr::cross_join() method.
See also
Other dplyr verbs that operate on pairs Spat*/data.frame:
bind_cols.SpatVector,
bind_rows.SpatVector,
filter-joins.SpatVector,
mutate-joins.SpatVector,
nest_join.SpatVector(),
rows.SpatVector
Other dplyr methods:
arrange.SpatVector(),
bind_cols.SpatVector,
bind_rows.SpatVector,
count.SpatVector(),
distinct.SpatVector(),
filter-joins.SpatVector,
filter.Spat,
glimpse.Spat,
group_by.SpatVector(),
mutate-joins.SpatVector,
mutate.Spat,
nest_join.SpatVector(),
pull.Spat,
reframe.SpatVector(),
relocate.Spat,
rename.Spat,
rows.SpatVector,
rowwise.SpatVector(),
select.Spat,
slice.Spat,
summarise.SpatVector()
Examples
v <- terra::vect(system.file("extdata/cyl.gpkg", package = "tidyterra"))
labels <- data.frame(period = c("past", "present"))
cross_join(v, labels)
#> class : SpatVector
#> geometry : polygons
#> dimensions : 18, 4 (geometries, attributes)
#> extent : 2892687, 3341372, 2017622, 2361600 (xmin, xmax, ymin, ymax)
#> coord. ref. : ETRS89-extended / LAEA Europe (EPSG:3035)
#> names : iso2 cpro name period
#> type : <chr> <chr> <chr> <chr>
#> values : ES-AV 05 Avila past
#> ES-AV 05 Avila present
#> ES-BU 09 Burgos past
#> ...
