Dear Amanda,,
I think this unwanted, nearly horizontal segment is unavoidable if you
simply plot() the results and you use a CRS such as 4326. Of course, you
can st_transform() your sf object to e.g. Robinson or Miller projection
before st_segmentize()-ing.
But this segment is correct in WGS-84 as well: its start and end points
are in the correct place. It is only a visualization decision whether
the start and end points are
1) connected with this unwanted line;
2) their connection is not displayed; or
3) 'connected' with two segments: one heading to the -180° longitude,
the other one heading to the +180° longitude.
HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences
2020.12.29. 0:24 keltezéssel, Amanda Rehbein írta:
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@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