I am using R and the sf package to manipulate shapefiles.
I have transect lines that intersect an island going a few hundred meters inland (see image below). The objective of my project is to trim each transect such that the inland portion is removed. I used sf::st_difference to clip these transect lines with the island shapefile:
However, for rivers, lagoons, and other locations the lines are cut multiple times. For my project, I only want to retain the outermost lines that intersect the coastline (below in red ) and want to remove the inland lines (below in blue). Could anyone recommend a good method to select only the outermost lines?