Add stations to contaminant data from an ICES extraction
Source:R/import_functions.R
add_stations.Rd
Adds the station name and station code to the contaminant data from an ICES extraction. This is done by either matching the station names submitted with the data to the station dictionary, or by matching the sample coordinates to the station dictionary, or a combination of both.
Arguments
- data
A data frame with the contaminant data from an ICES extraction
- stations
A data frame with the ICES station dictionary
- info
A HARSAT information list which must contain the elements
purpose
,compartment
, andadd_stations
. The latter is a list of control parameters supplied throughcontrol_default
orcontrol_modify
which control how the station matching is achieved. See details.
Value
A data frame containing the contaminant data augmented by variables containing the station code and the station name
Details
info$add_stations
is a list of control parameters that modify the
station matching process:
method: a string specifying whether the stations are matched by
"name"
,"coordinates"
, or"both"
. Ifinfo$purpose
is"custom"
,method
is restricted to either"name"
(the default) or"coordinates"
. Ifinfo$purpose
is"OSPAR"
,"HELCOM"
or"AMAP"
, then method is set to"both"
by default and stations are matched by name or coordinates according to rules specified by OSPAR, HELCOM or AMAP data providers. Specifically, stations are matched by name for Denmark, France (biota and water - all years; sediment 2009 onwards), Ireland, Norway, Portugal, Spain (2005 onwards), Sweden, The Netherlands (2007 onwards), United Kingdom. All other stations are matched by coordinates.area: a vector of strings containing one or more of
"OSPAR"
,"HELCOM"
and"AMAP"
; this restricts the stations to those in the corresponding convention area(s); NULL matches to all stations in the station dictionarydatatype: a logical specifying whether the stations should be restricted to those with an appropriate datatype. If
TRUE
, a contaminant measurement in biota (for example) will only be matched to stations withstation_datatype
containing the string"CF"
. Similarly, a biological effect measurement in biota will only be matched to stations withstation_datatype
containing the string"EF"
temporal: a logical with
TRUE
indicating that stations should be restricted to those withstation_purpm
containing the string"T"
governance_type: a string:
"none"
,"data"
,"stations"
or"both"
."none"
means data and station governance are both ignored."data"
means that matching will be restricted by data governance but not station governance; for example ifgovernance_id == c("OSPAR", "AMAP")
, then data will only be matched to a station if one ofis_ospar_monitoring
andis_amap_monitoring
isTRUE
, with all stations considered regardless of station governance."stations"
mean that matching will be restricted by station governance but not by data governance; for example ifgovernance_id == c("OSPAR", "AMAP")
, then the stations will be restricted to those wherestation_programgovernance
contains either"OSPAR"
or"AMAP"
, with all data considered regardless of data governance.both
uses both data and station governance. Ifgovernance_id
contains a single value, then the matching is strict. However, ifgovernance_id
contains multiple values, then the matching is more complicated. For example, ifgovernance_id == c("OSPAR", "AMAP")
, then measurements withis_ospar_monitoring == TRUE
and"is_amap_monitoring == FALSE"
are matched to stations wherestation_programgovernance
contains"OSPAR"; measurements with
is_ospar_monitoring == FALSEand
is_amap_monitoring == TRUEare matched with stations where
station_programgovernancecontains
"AMAP"; but measurements where
is_ospar_monitoring == TRUEand
is_amap_monitoring == TRUEare matched to stations where
station_programgovernancecontains either
"OSPAR"or
"AMAP"`.governance_id: a vector of strings containing one or more of
"OSPAR"
,"HELCOM"
and"AMAP"
.grouping: a logical with
TRUE
indicating that stations will be grouped into meta-stations as specified bystation_asmtmimeparent
in the station dictionary. Defaults toFALSE
apart from wheninfo$purpose == "OSPAR"
.check_coordinates: a logical with
TRUE
indicating that, when stations are matched by name, the sample coordinates must also be within the station geometry. No implemented yet, so defaults otFALSE
.