Spatial Join with Optional Mask Filtering and Column Selection
Source:R/ngr_spk_join.R
ngr_spk_join.Rd
Joins 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_tbl
from 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()
.
Value
A sf object with the result of the spatial join. If target_col_return
is not "*", only selected columns are returned.
See also
Other spacehakr:
ngr_spk_ext_raster()
,
ngr_spk_gdalwarp()
,
ngr_spk_layer_info()
,
ngr_spk_odm()
,
ngr_spk_poly_to_points()
,
ngr_spk_res()