[R-sig-Geo] st_segmentize across east and west hemispheres

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Tue Dec 29 13:54:18 CET 2020


You may want to look into st_wrap_dateline(), which cuts LINESTRING and 
POLYGON geometries in multi-part equivalents where parts do not cross 
the antimeridian.

As in:

seg2 <- st_segmentize(st_wrap_dateline(sf), units::set_units(1000, km))


On 29/12/2020 00:24, Amanda Rehbein wrote:
> Dear r-sig-geo list,
> 
> I have a package called raytracing for calculating atmospheric Rossby wave
> paths.
> I need to get segments of the great circle or routes from some geographical
> coordinates. st_segmentize is calculating them correctly. However, when I
> need to connect two points in different hemispheres, east and west, it
> creates an unwanted horizontal line, as shown in the following example. Is
> it possible (and correct) to avoid or remove this horizontal line?
> 
> 
> library(sf)
> m <- rbind(c(100,-50),
>             c(-100,50))
> sf <- st_sf(a=1,
>             geom=st_sfc(st_linestring(m)),
>             crs = 4326)
> seg <- st_segmentize(sf, units::set_units(1000, km))
> plot(seg, axes = TRUE, reset = FALSE, type = "p", pch = 16)
> plot(seg$geom, add = TRUE, col = "red")
> text(x = m[, 1], y = m[, 2] - 7, label = 1:2, col = "blue")
> 
> Many thanks.
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list