select_between_polygons {psyosphere} | R Documentation |
Select tracks between a start and a finish polygon. Only the data between the polygons will remain. Data that is not between the start and finish polygon will be disregarded. If a track passes multiple times first the start and then the finish will be split up in rounds and new track id's will be created for each round.
select_between_polygons( tracks, poly1, poly2, t_id = "id", merge_id = TRUE )
tracks |
|
poly1 |
data frame. A data frame with the columns lon (numeric) and lat (numeric). All coordinates will be selected that start after leaving this polygon and enter polygon_finish. The polygon should be closed, therefore the first and last coordinate must be the same. See also |
poly2 |
data frame. A data frame with the columns lon (numeric) and lat (numeric). All coordinates will be selected that start after leaving |
t_id |
character or numeric. Column name in |
merge_id |
logical. If |
The following image shows a track before selection.
The following image shows a track after selection with 3 rounds.
Benjamin Ziepert. Please send feedback to: feedback-psyosphere@analyse-gps.com.
# Create polygons lon <- c(6.849975, 6.849627, 6.850001, 6.850350, 6.849975) lat <- c(52.241745, 52.241100, 52.241004, 52.241649, 52.241745) polygon_start <- data.frame(lon, lat) remove(lon, lat) lon <- c(6.851810, 6.851000, 6.851489, 6.852296, 6.851810) lat <- c(52.241800, 52.240300, 52.240163, 52.241657, 52.241794) polygon_finish <- data.frame(lon, lat) remove(lon, lat) # Get a track data(psyo_rounds) data(psyo_rounds_map) # Plot tracks plot <- psyosphere::plot_tracks(psyo_rounds, t_id = "", plot = psyo_rounds_map) # plot <- psyosphere::plot_tracks(psyo_rounds, zoom = 17, t_id = "") plot # Add start and finish polyon plot <- psyosphere::plot_polygon(polygon_start, plot = plot) psyosphere::plot_polygon(polygon_finish, plot = plot) remove(plot) # Select data between polygon psyo_rounds <- psyosphere::select_between_polygons( psyo_rounds, polygon_start, polygon_finish ) # Plot the remaining data plot <- psyosphere::plot_tracks(psyo_rounds, t_id = "", plot = psyo_rounds_map) # plot <- psyosphere::plot_tracks(psyo_rounds, zoom = 17, t_id = "") plot <- psyosphere::plot_polygon(polygon_start, plot = plot) psyosphere::plot_polygon(polygon_finish, plot = plot)