Validate longitude and latitude vectors to ensure they are numeric,
have matching lengths, and contain values within valid geographic bounds.
validateLonsLats(longitude = NULL, latitude = NULL, na.rm = FALSE)
Arguments
- longitude
Vector of longitudes in decimal degrees east.
- latitude
Vector of latitudes in decimal degrees north.
- na.rm
Logical specifying whether to remove NA values before
validation.
Value
Invisibly returns TRUE if validation succeeds.
Details
Longitudes must fall between -180 and 180 degrees and latitudes must
fall between -90 and 90 degrees. If validation fails, an error is
generated.
Examples
longitude <- c(-122.5, -122.4)
latitude <- c(47.5, 47.6)
validateLonsLats(longitude, latitude)
# Remove missing values before validation
validateLonsLats(
c(-122.5, NA),
c(47.5, NA),
na.rm = TRUE
)
if (FALSE) { # \dontrun{
validateLonsLats(c(-200, 0), c(45, 46))
} # }