Extract Station Coordinates Robustly (internal)
Source:R/int_extract_coordinates.R
smn_int_extract_coordinates.RdRetrieves the metadata lines for a given station using the URL generated by
smn_int_get_url(), searches for lines containing latitude/longitude/altitude
labels (case-insensitive, ES/EN variants), and extracts the first numeric
value from each line. If a coordinate cannot be extracted or fails range
validation, NA is returned for that coordinate.
Usage
smn_int_extract_coordinates(
station,
max_attempts = 10,
encoding = "UTF-8",
add_meta_cols = FALSE
)Arguments
- station
Station code (character or numeric).
- max_attempts
Integer. Maximum retries for the metadata download (default
10).- encoding
Character. Encoding for
readLines()(default"UTF-8").- add_meta_cols
Logical. If
TRUE, includestationandsource_urlas explicit columns in the returned data (defaultFALSE). These are always attached as attributes for provenance.