Skip to contents

Validates specific station IDs against the SNIRH database and returns their current status. This is useful for checking stations before running the full conversion process.

Usage

check_station_status(station_ids, matrix = "surface.water")

Arguments

station_ids

Character vector of station IDs to check.

matrix

Character string specifying the matrix type. Currently supports "surface.water" and "biota". Default is "surface.water".

Value

A data.table with the following columns:

station_id

The station ID that was checked

found

Logical indicating if station exists in SNIRH

status

Station status if found, NA if not found

active

Logical indicating if station is active (status = "ATIVA")

Details

This function is particularly useful for:

  • Pre-validating station IDs before data conversion

  • Checking why certain stations fail validation

  • Getting an overview of station status for reporting

See also

get_snirh_stations for getting all station information

convert_to_snirh for the main conversion function

Examples

# \donttest{
# Check status of specific stations
my_stations <- c("07G/50", "25G/07", "INVALID_ID")
status_check <- check_station_status(my_stations)
#> ! Missing from SNIRH: "INVALID_ID"
print(status_check)
#> Index: <found>
#>    station_id  found status active
#>        <char> <lgcl> <char> <lgcl>
#> 1:     07G/50   TRUE  ATIVA   TRUE
#> 2:     25G/07   TRUE  ATIVA   TRUE
#> 3: INVALID_ID  FALSE   <NA>     NA

# Check which stations are not active
inactive <- status_check[active == FALSE | is.na(active)]
if (nrow(inactive) > 0) {
  print("Stations requiring attention:")
  print(inactive)
  }
#> [1] "Stations requiring attention:"
#>    station_id  found status active
#>        <char> <lgcl> <char> <lgcl>
#> 1: INVALID_ID  FALSE   <NA>     NA

# Check only active stations
active_stations <- status_check[active == TRUE]
# }