A logical vector is created with either TRUE
or
FALSE
for each incoming longitude, latitude
pair with
TRUE
indicating a valid location. This can be used to filter dataframes
to retain only records with valid locations.
lonRange
and latRange
can be used to create a valid-mask for
locations within a rectangular area.
removeZeroZero
will invalidate the location 0.0, 0.0
which is
sometimes seen in poorly QC'ed datasets.
NA
values found in longitude
or latitude
will result
in a mask value of FALSE
.
Vector of longitudes in decimal degrees E.
Vector of latitudes in decimal degrees N.
Range of valid longitudes.
Range of valid latitudes.
Logical indicating whether locations at 0.0, 0.0
should be marked as invalid.
Vector of logical values.
library(MazamaCoreUtils)
createLocationMask(
longitude = c(-120, NA, -120, -220, -120, 0),
latitude = c(45, 45, NA, 45, 100, 0)
)
#> [1] TRUE FALSE FALSE FALSE FALSE FALSE
createLocationMask(
longitude = c(-120:-90),
latitude = c(20:50),
lonRange = c(-110, -100),
latRange = c(30, 40)
)
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
#> [13] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE
#> [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE