sf
sf copied to clipboard
st_intersection (with missing y) produces "degenerate" polygons
Describe the bug
I'm using the st_intersection() function on a single sf object with overlapping polygons to extract the geometries with and without overlap. The polygons of the overlapping parts are OK, but the non-overlapping polygons almost always have some zero-width "part".
To Reproduce Using the attached data, polygons 1 and 3 have a zero-width part while polygon 2 is OK. testinter.zip
library(sf)
pols <- st_read("testinter.gpkg", "pols")
inter <- st_intersection(pols)
par(mfrow = c(1, 3))
plot(st_geometry(inter[1,]))
plot(st_geometry(inter[2,]))
plot(st_geometry(inter[3,]))
Additional context
Thanks a lot for all your work on the sf package!
sessionInfo()
R version 4.4.2 (2024-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale: [1] LC_COLLATE=German_Switzerland.utf8 LC_CTYPE=German_Switzerland.utf8 LC_MONETARY=German_Switzerland.utf8 [4] LC_NUMERIC=C LC_TIME=German_Switzerland.utf8
time zone: Europe/Zurich tz
attached base packages: [1] stats graphics utils datasets grDevices methods base
other attached packages: [1] sf_1.0-19
loaded via a namespace (and not attached):
[1] compiler_4.4.2 magrittr_2.0.3 class_7.3-23 tools_4.4.2 DBI_1.2.3 units_0.8-5
[7] proxy_0.4-27 Rcpp_1.0.14 KernSmooth_2.23-26 grid_4.4.2 e1071_1.7-16 classInt_0.4-11
sf::sf_extSoftVersion()
GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H PROJ
"3.12.2" "3.9.3" "9.4.1" "true" "true" "9.4.1"