-
Notifications
You must be signed in to change notification settings - Fork 301
Description
Hi,
I have a large sfc (MULTIPOLYGON) objects which throw several TopologyException errors when I try to use the intersection function on them. I have a couple of questions so, If anyone has a moment, I would really appreciate it if you could take a look at this. I've attached the files in RDS format (all). Below is some example code.
all<-readr::read_rds("all.rds")
None of these lines seems to work:
all %>% st_intersection
all %>% st_set_precision(1000000) %>% lwgeom::st_make_valid %>% st_intersection
all %>% st_set_precision(1000) %>% lwgeom::st_make_valid %>% st_intersection
-
sf::st_is_valid
returnsTRUE
for all objects. I've tried usingmapview
,lwgeom::st_make_valid
and modifying the precision of the calculations. Only when I set precision to 100 or lower, the "rounded coordinates" become valid geometries to execute thest_intersection
function. This issue is related to discussions in #600 and #603. The problem for me is that rounding the coordinates (two decimal places) does not seem appropriate for the work I'm doing. I tried several strategies including rounding (and using st_make_valid) the coordinates just for next rows (sfg):
all %>% st_set_precision(100) %>% lwgeom::st_make_valid %>% sf::st_is_valid
However, the issue remains. -
A subset of the data that generates one of the TopologyException errors is:
subset<-all %>% subset(id %in% c(47,98,158))
st_intersection(subset)
I imagine I am off-track here but It seems tricky to me that the st_intersection of these three multipolygons do not work but pairwise-intersections of these rows do not generate any error. Could you please let me know what I am missing?
int12<-st_intersection(subset[c(1,2),])
int13<-st_intersection(subset[c(1,3),])
int23<-st_intersection(subset[c(2,3),])
Apologies if I've posted this in the wrong place. I hope I am not completely off-track. In case, feel free to delete this.