filter_positions_at_range: Retain only positions within a range from a location.

View source: R/utils-spatial.R

filter_positions_at_rangeR Documentation

Retain only positions within a range from a location.

Description

The points whose distance, .distance, satisfies

dm <= .distance < dM

are kept (.exclude = FALSE) or excluded (.exclude = TRUE)

Usage

filter_positions_at_range(
  df,
  geo,
  dm,
  dM,
  lon,
  lat,
  .exclude = FALSE,
  .keep = FALSE
)

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]

Value

a subset of df

See Also

Other spatial: bbox_at_distance(), bounding_box(), crs_tc(), polygon_at_distance(), polygon_from_coords()

Examples

## Not run: 
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)

## End(Not run)

euctrl-pru/trrrj documentation built on April 15, 2024, 1:24 p.m.