Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split(SpatVector, SpatVector) problem #1619

Open
mdsumner opened this issue Oct 14, 2024 · 1 comment
Open

split(SpatVector, SpatVector) problem #1619

mdsumner opened this issue Oct 14, 2024 · 1 comment

Comments

@mdsumner
Copy link
Contributor

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?

@rhijmans
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants