sf
sf copied to clipboard
check validity of polygon geometry, cast to single polygons and remove holes
Hi,
I am using the sf package to check validity of polygon geometry, cast to single polygons and remove holes. Unfortunately, my code fails
polygon = st_make_valid(polygon) %>% sf_remove_holes() %>% st_cast("MULTIPOLYGON" ) %>% st_cast("POLYGON")
and gives me the warning message
In st_cast.sf(., "POLYGON") :
repeating attributes for all sub-geometries for which they may not be constant
Is here someone that can help with this issue?
What is the issue?
What is the issue?
Thank you for your response.
Basically, the same issue that is described here: https://github.com/r-spatial/sf/issues/323#event-1063195119
This code works:
polygon = st_cast(polygon, "POLYGON")
But this code is not working:
polygon = st_make_valid(polygon) %>% st_cast("MULTIPOLYGON") %>% st_cast("POLYGON")
I dont understand why and unfortunately cannot follow your response to question #323.
st_make_valid(pol) %>% st_cast("MULTIPOLYGON" ) %>% st_cast("POLYGON")
works, sf_remove_holes is not an sf function.