Learn R Programming

snirh.lab (version 0.1.0)

get_snirh_stations: Get SNIRH station information

Description

Downloads and returns information about SNIRH monitoring stations for surface water quality. This function can be used to check station status, get available station IDs, or validate stations before data conversion.

Usage

get_snirh_stations(matrix = "surface.water", timeout = 30, active_only = FALSE)

Value

A data.table with station information containing:

station_id

Station identifier (corresponds to "Código" in SNIRH)

status

Station status (e.g., "ATIVA", "EXTINTA")

geometry

Spatial geometry (if sf package is available)

Arguments

matrix

Character string specifying the matrix type. Currently supports "surface.water" and "biota" (both use the same station database).

timeout

Numeric. Timeout in seconds for downloading data. Default is 30.

active_only

Logical. If TRUE, returns only active stations (Estado = "ATIVA"). If FALSE, returns all stations. Default is FALSE.

Station Status

Stations can have different status values:

ATIVA

Station is active and can receive new data

INATIVA

Station is inactive (historical data only)

EXTINTA

Station is permanently suspended and has no data

Details

Downloads the latest station information from the SNIRH geoportal. It requires an internet connection and the 'sf' package for processing shapefiles.

The station database includes information about:

  • Station location (coordinates)

  • Station status (active/inactive)

  • Station metadata

See Also

convert_to_snirh for the main conversion function

check_station_status for checking specific stations

Examples

Run this code
# \donttest{
# Get all surface water stations
all_stations <- get_snirh_stations("surface.water")
print(head(all_stations))

# Get only active stations
active_stations <- get_snirh_stations("surface.water", active_only = TRUE)
print(paste("Active stations:", nrow(active_stations)))

# Check if specific stations are active
my_stations <- c("07H/50", "25G/07")
station_info <- get_snirh_stations("surface.water")
station_status <- station_info[station_id %in% my_stations]
print(station_status)
# }

Run the code above in your browser using DataLab