mergeDataframeWithLayer: Merge (join) a dataframe with (to) a geometry layer

View source: R/mergeDataframeWithLayer.R

mergeDataframeWithLayerR Documentation

Merge (join) a dataframe with (to) a geometry layer

Description

This function merges (joins) a dataset with (to) a geometry layer.

Usage

mergeDataframeWithLayer(
  dfr,
  geoms,
  dataID = "GIS_STATION",
  geomsID = "STATION_ID",
  sfJoinType = c("right join", "left join", "inner join", "full join"),
  spAllData = FALSE,
  spDuplicateGeoms = TRUE
)

Arguments

dfr
  • dataframe to merge

geoms
  • geometries to merge with

dataID
  • name of id column in dataframe to join on

geomsID
  • name of id column in geometry layer to join on

sfJoinType
  • join type (dfr to geoms) for sf-like geometries

spAllData
  • flag to merge all rows from dataframe with sp-like geometries

spDuplicateGeoms
  • allow sp-like geoms to be duplicated (i.e., where multiple rows in dataframe maatch a single geom)

Details

Uses packages dplyr, sf and sp. If geoms is an sp dataset, the merge is conducted using sp:merge. If geoms is an sf dataset, it is conducted using one of the join functions in package dplyr. The results of this join will depend on the join type:

  • right join: matched rows in dfr, all rows in geoms

  • left join: all rows in dfr, matched rows in geoms

  • inner join: only rows in dfr matched to geoms

  • full join: all rows in dfr and all rows in geoms

The join column will take its name from dataID in dfr and will not include a column named geomsID.

Value

  • sf or sp dataframe (depending on the class of the geoms object).


wStockhausen/wtsGIS documentation built on Aug. 23, 2023, 2:31 a.m.