terra icon indicating copy to clipboard operation
terra copied to clipboard

split(SpatVector, SpatVector) problem

Open mdsumner opened this issue 1 year ago • 1 comments

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?

mdsumner avatar Oct 14 '24 12:10 mdsumner

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))
Screenshot

rhijmans avatar Oct 15 '24 02:10 rhijmans

Reverted to an older version that worked.

rhijmans avatar Dec 18 '24 20:12 rhijmans