sf
sf copied to clipboard
st_intersection creates new geometries and generates geometry errors
Hi everyone,
I'm new to GitHub and Spatial Data. However, I've not seen the answer of my following question on the older issues nor on StackOverflow.
The idea is that I'm trying to self intersect polygons, according to this link : https://r-spatial.github.io/sf/reference/geos_binary_ops.html
Please find attached the reproducible data I'm working on. It corresponds to "rings" inside each other. The rings are defined in such a way that a rings inside another one are not supposed to intersect. Hence, rings with ID 1, 2, 3 do not overlap, same for 4, 5, and 6, 7, and 8, 9 and 10, 11.
The overall goal is to count the number of rings that overlap between each other, using the n.overlap output of st_intersection.
When calling for st_intersection, the plot doesn't look accurate: some overlaps are missing on the right side of the figure, and some circles or lines are added. Moreover, I get geometry errors, how can I access them or interprete them ?
I think my issue is quite related to this one, https://github.com/r-spatial/sf/issues/1668, however I cannot solve it properly. Any help would be much appreciated.
library(sf)
circles <- st_read("circles.shp")
plot(st_geometry(circles), col = alpha(1:nrow(circles), 0.4))

intersection <- st_intersection(circles)
plot(st_geometry(intersection), col = 1:nrow(intersection))

Thanks in advance for your help. Best regards,
Vincent circles.zip