Skip to contents

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.

Usage

add_stations(data, stations, info)

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, and add_stations. The latter is a list of control parameters supplied through control_default or control_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". If info$purpose is "custom", method is restricted to either "name" (the default) or "coordinates". If info$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 dictionary

  • datatype: 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 with station_datatype containing the string "CF". Similarly, a biological effect measurement in biota will only be matched to stations with station_datatype containing the string "EF"

  • temporal: a logical with TRUE indicating that stations should be restricted to those with station_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 if governance_id == c("OSPAR", "AMAP"), then data will only be matched to a station if one of is_ospar_monitoring and is_amap_monitoring is TRUE, 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 if governance_id == c("OSPAR", "AMAP"), then the stations will be restricted to those where station_programgovernance contains either "OSPAR" or "AMAP", with all data considered regardless of data governance. both uses both data and station governance. If governance_id contains a single value, then the matching is strict. However, if governance_id contains multiple values, then the matching is more complicated. For example, if governance_id == c("OSPAR", "AMAP"), then measurements with is_ospar_monitoring == TRUE and "is_amap_monitoring == FALSE" are matched to stations where station_programgovernance contains "OSPAR"; measurements with is_ospar_monitoring == FALSEandis_amap_monitoring == TRUEare matched with stations wherestation_programgovernancecontains"AMAP"; but measurements where is_ospar_monitoring == TRUEandis_amap_monitoring == TRUEare matched to stations wherestation_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 by station_asmtmimeparent in the station dictionary. Defaults to FALSE apart from when info$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 ot FALSE.