Retain only positions within a range from a location.
Source:R/utils-spatial.R
filter_positions_at_range.Rd
The points whose distance, .distance
, satisfies
$$dm <= .distance < dM$$
are kept (.exclude = FALSE
) or excluded (.exclude = TRUE
)
Arguments
- df
a (trajectory) data frame
- geo
a geographical location in lon/lat (WGS84)
- dm
a distance in Nautical Miles
- dM
a distance in Nautical Miles
- lon
the column for longitude in
df
- lat
the column for latitude in
df
- .exclude
exclude the point in the (
dm
,dM
) [default is FALSE]- .keep
keep the calculated distance (in Nautical Miles) in the
.distance
column [default is FALSE]
See also
Other spatial:
bbox_at_distance()
,
bounding_box()
,
crs_tc()
,
polygon_at_distance()
,
polygon_from_coords()
Examples
if (FALSE) {
fra <- c(8.570556, 50.03333) # Frankfurt Airport (longitude, latitude)
# keep the points 40 NM from FRA
poss %>% filter_positions_at_range(fra, 0, 40, longitude, latitude)
# keep the points from 10 to 40 NM from FRA
poss %>% filter_positions_at_range(fra, 10, 40, longitude, latitude)
# exclude the points from 10 to 40 NM from FRA
poss %>% filter_positions_at_range(fra, 10, 40, longitude, latitude, .exclude = TRUE)
# keep the points further away of 40 NM from FRA
poss %>% filter_positions_at_range(fra, 0, 40, longitude, latitude, .exclude = TRUE)
}