match_sites {cubble} | R Documentation |
Match stations in two cubbles by spatial distance/ temporal similarity
Description
The spatial matching is calculated using sf::st_distance()
with different
distance (in meter or degree) available depending on the coordinate reference
system and parameter (which
and par
). The temporal matching is based on
a temporal matching function (temporal_match_fn
) that can be customised.
Usage
match_sites(
df1,
df2,
crs = sf::st_crs("OGC:CRS84"),
which = NULL,
par = 0,
spatial_n_each = 1,
spatial_n_group = 4,
data_id,
match_id,
temporal_matching = TRUE,
temporal_by,
temporal_match_fn = match_peak,
temporal_n_highest = 20,
temporal_window = 5,
...
)
match_spatial(
df1,
df2,
crs = sf::st_crs("OGC:CRS84"),
which = NULL,
par = 0,
spatial_n_each = 1,
spatial_n_group = 4,
return_cubble = FALSE
)
match_temporal(
data,
data_id,
match_id = NULL,
temporal_by,
return_cubble = FALSE,
temporal_match_fn = match_peak,
temporal_n_highest = 30,
temporal_window = 5,
...
)
Arguments
df1 , df2 |
the two cubble objects to match |
crs |
a crs object from |
which |
character; for Cartesian coordinates only: one of |
par |
for |
spatial_n_each |
integer, the number of matched "station" in |
spatial_n_group |
integer, the number of matched group (pair) return |
data_id |
a character (or symbol), the variable differentiates
|
match_id |
a character (or symbol), the variable differentiate each group of match |
temporal_matching |
logical, whether to match temporally |
temporal_by |
in the |
temporal_match_fn |
character, the function name on how two time series should be matched |
temporal_n_highest |
numeric, the number of highest peak used for
temporal matching in |
temporal_window |
The temporal window allowed in |
... |
parameters passing to temporal match |
return_cubble |
logical (default to false), whether to return the cubble object or a matching summary table |
data |
the resulting cubble object from spatial matching (with
|
Examples
library(dplyr)
climate_aus <- mutate(climate_aus, type = "climate")
match_spatial(climate_aus, river)
# turn with different distance calculation:
match_spatial(climate_aus, river, which = "Hausdorff")
# tune the number of matches in each group
match_spatial(climate_aus, river, spatial_n_each = 5, spatial_n_group = 2)
a1 <- match_spatial(climate_aus, river, return_cubble = TRUE) |> bind_rows()
match_temporal(a1, data_id = type, match_id = group,
temporal_by = c("prcp" = "Water_course_level"))