Merges two or more GeoLocator Data Package objects into a single combined package. The metadata properties from both packages are merged according to specific rules, and resource data is combined based on their presence in either package.
Details
Input formats:
merge_gldp(x, y, ...)merge_gldp(list(x, y, ...))merge_gldp(x, list(y, ...))
Resource merging logic:
A resource is added even if only one input package contains it.
For each resource, rows from available inputs are combined with
dplyr::bind_rows().Custom resources (not GeoLocator-DP tables) are dropped from the merged package, with a message naming them.
Check for unique tag_id:
The merge aborts if any
tag_idis present in both packages. Drop it from one package withselect_gldp(), or rename it in every table and inparamsof one package.
datapackage_id in tags:
For the
tagsresource, each row must have adatapackage_id.Missing
datapackage_idvalues are filled with the packageid, so the merge aborts when such a package has noid.The merge aborts if
tags$datapackage_idoverlaps between the two inputs.
Metadata merging rules:
$schema: The latest GeoLocator-DP version, as set bycreate_gldp(). The source packages'versionis not kept on the merged package; it is listed indatapackages$version.title: Combined from both packages, separated by a "/".
contributors: Combined from both packages. Entries for the same person (same ORCID in
path, or the same name when no ORCID is given) are merged into one, keeping the first entry's name and the union ofrolesandorganization. Each source package's own list is preserved indatapackages$contributors.licenses: Combined, with duplicates removed.
record_type: Combined from both packages, with duplicates removed.
codeRepository: Combined from both packages, with duplicates removed.
datapackages: Carries the merged provenance table described above.
relatedIdentifiers: Combined, with duplicates removed, and each unique source
datapackage_id(or packageid) is added asIsCompiledBy, a DOI without itshttps://doi.org/prefix.params: Concatenated from all inputs; every entry must contain a non-empty
param$id.created: Set to the current timestamp at the time of merging.
All others are dropped.
datapackages provenance table:
pkg$datapackagesis a one-row-per-source tibble keyed bydatapackage_id(pkg$id) and accumulated across sequential merges.It includes key source metadata fields (e.g. title/version/status/access), temporal coverage (
temporal_start,temporal_end), taxonomic summary (taxonomic), and resource/sensor counts asnumberTags_*columns.
See also
create_gldp() to create package shells and update_gldp() for the
derived properties recomputed on the merged package.
Examples
if (FALSE) { # \dontrun{
pkg1 <- read_zenodo("17367319", quiet = TRUE)
pkg2 <- read_zenodo("17257520", quiet = TRUE)
merged <- merge_gldp(pkg1, pkg2)
merged
# List-style input is also supported
merged <- merge_gldp(list(pkg1, pkg2))
} # }
