# Apply the selection function
result <- selection(for_rail_gtfs,
stop_id == for_rail_gtfs$stops$stop_id[1] & trip_id %in% for_rail_gtfs$trips$trip_id[1:5])
# Check the selection
class(result)
attr(result, 'selection')
# Use geometry selection
bbox <- sf::st_bbox(c(
xmin = -38.57219059002416,
ymin = -3.7999496173114118,
xmax = -38.50455165901261,
ymax = -3.756631724636505
),
crs = sf::st_crs(4326)) # Set CRS to WGS 84
# Convert the bounding box to a polygon
polygon <- sf::st_as_sfc(bbox)
result <- selection(for_rail_gtfs, geometry %intersects% polygon)
Run the code above in your browser using DataLab