You make it look so easy! That is just what I was trying to noodle out. I need to spend more time digging into the [s2](https://r-spatial.github.io/s2/index.html) package. Thank you!
On Wed, Jun 5, 2024 at 1:09 PM Dewey Dunnington <de...@dunnington.ca> wrote: > > Hi Ben, > > I had a bit of fun with this [1]...the act of following a shortest path > and finding the endpoints are sort of related (in that if you follow the > shortest path setting a maximum distance threshold, eventually you will > fail to find any more points, and you've found (maybe) and endpoint!). > > I hope this is helpful! > > Cheers, > > -dewey > > [1] https://gist.github.com/paleolimbot/0be47836de5008f308959923dac02c5b > > On 2024-06-05 13:20, Ben Tupper wrote: > > Hello, > > > > NOAA's Ocean Prediction Center (https://ocean.weather.gov/) serves the > > US Navy's almost-daily estimate of the locations of the north and > > south walls of the Gulf Stream in the North Atlantic > > (https://ocean.weather.gov/gulf_stream_latest.txt). The also serve an > > archive via a FTP server > > (https://ftp.opc.ncep.noaa.gov/grids/experimental/GStream) for > > downloads by year. The dataset provides manually estimated of > > locations along the so-called north and south walls of the Gulf > > Stream, although there is ongoing research and debate about the best > > way to define the Gulf Stream. My colleagues and I have been slowly > > pulling together a small package to make working with this data easier > > (https://github.com/BigelowLab/gstream). > > > > This dataset provides an interesting spatial puzzle because the points > > for a specific wall on a given date are not ordered. Assuming that > > the points could be ordered into LINESTRING, the problem is how to do > > it. > > > > We probably can use sfnetworks package > > (https://luukvdmeer.github.io/sfnetworks/) extensive tools to follow a > > shortest path... but first one of the two endpoints must be found. > > Eeek! How does one do that programmatically? The plot attached shows > > the points for the north wall on 2020-12-19. Also shown are the first > > and last points in the record which are clearly not the endpoints of a > > path we might assemble from the points. > > > > #### START > > suppressPackageStartupMessages({ > > library(sf) > > library(readr) > > library(dplyr) > > }) > > > > > > file = > > "https://raw.githubusercontent.com/BigelowLab/gstream/main/inst/examples/2020-12-19-north.csv" > > x = readr::read_csv(file, col_types = "nn") |> > > sf::st_as_sf(coords = c("X", "Y"), crs = 4326) |> > > sf::st_as_sf() > > > > > > p = sf::st_cast(dplyr::select(x, attr(x, "sf_column")), "POINT") > > plot(sf::st_geometry(x), type = "b", axes = TRUE, reset = FALSE) > > plot(dplyr::slice(p,1), col = "orange", add = TRUE, pch = 2, cex = 1.5) > > plot(dplyr::slice(p,nrow(x)), col = "orange", add = TRUE, pch = 6, cex > > = 1.5) > > ### END > > > > -- > > > > Ben Tupper he/him > > > > Research Associate > > > > Bigelow Laboratory for Ocean Sciences > > > > ––––––––––––––––––––––––––––––––––––––––––––––––––– > > > > E btup...@bigelow.org > > > > O 207-315-2567 > > > > ––––––––––––––––––––––––––––––––––––––––––––––––––– > > > > Bold Science for Our Blue Planet | BIGELOW.ORG > > > > 60 BIGELOW DRIVE | EAST BOOTHBAY, MAINE 04544 USA > > > > _______________________________________________ > > R-sig-Geo mailing list > > R-sig-Geo@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo