Spatial Join with Optional Mask Filtering and Column Selection
Source:R/ngr_spk_join.R
ngr_spk_join.RdJoins a target sf::sf object with a mask sf::sf object using a specified spatial predicate. Optional filtering and selection of columns from the mask can be applied.
Usage
ngr_spk_join(
target_tbl,
mask_tbl,
target_col_return = "*",
mask_col_return = NULL,
mask_col_filter = NULL,
mask_col_filter_values = NULL,
mask_col_filter_values_negate = FALSE,
join_fun = sf::st_intersects,
path_gpkg = NULL,
collapse = FALSE,
target_col_collapse = NULL,
...
)Arguments
- target_tbl
sf::sf The target table to be spatially joined.
- mask_tbl
character or sf::sf The mask table name (if reading from
path_gpkg) or an sf object.- target_col_return
character A vector of target column names to retain. Use "*" to retain all.
- mask_col_return
character or NULL Optional. A vector of mask column names to retain. Default is
NULL.- mask_col_filter
character or NULL Optional. A single mask column name used for filtering rows.
- mask_col_filter_values
character or NULL Optional. Values to match (or exclude) in
mask_col_filter.- mask_col_filter_values_negate
logical Whether to exclude (
TRUE) or include (FALSE) matching rows. Default isFALSE.- join_fun
function Spatial predicate function from
sf::st_intersects(),sf::st_within(), etc. Default issf::st_intersects.- path_gpkg
character or NULL Optional. Path to a GeoPackage to read
mask_tblfrom if not already an sf object.- collapse
logical Whether to collapse results to one amalgamated row with multiple results when more than one result is returned. Default is TRUE
- target_col_collapse
character or NULL Optional. A target column name to group by to facilitate collapsing the result.
- ...
Additional arguments passed to
sf::st_join().