terra
terra copied to clipboard
split(SpatVector, SpatVector) problem
Here I don't see splitting occuring everywhere expected.
library(terra)
#> terra 1.7.78
v <- vect(system.file("ex/lux.shp", package="terra"))[1:5, ]
## split geometries
line <- vect(matrix(c(5.79, 6.22, 5.75, 6.1, 5.8,
50.14, 50.05, 49.88, 49.85, 49.71), ncol=2), "line")
s <- split(v, line)
op <- par(mfrow= n2mfrow(nrow(s)))
for (i in 1:nrow(s)) {plot(line, main = i); plot(s[i, ], add = TRUE)}
par(op)

Created on 2024-10-14 with reprex v2.0.2
Panels 5 and 6 show splitting (from the polygon in panel 1). But, should we expect all polygons to be sliced where a line crosses them? And for the inputs to be removed replaced by the parts?
I do not know why this does not work. With an older terra/geos I get a better result
library(terra)
terra 1.7.38
gdal(lib="all")
gdal proj geos
"2.2.3" "4.9.3" "3.6.2"
plot(s, col=rainbow(13))
Reverted to an older version that worked.