I have the two following files in R:
Bigger Units : https://www150.statcan.gc.ca/n1/pub/82-402-x/2018001/data-donnees/boundary-limites/arcinfo/HR_000a18a-eng.zip
I am trying to now perform a merge on these files:
library(sf)
Bigger_Units <- sf::st_read("C:/Users/ME/OneDrive/Documents/hr_shape/HR_000a18a_e.shp", options = "ENCODING=WINDOWS-1252") %>%
st_transform(crs = 4326)
Smaller_Units <- sf::st_read("C:/Users/ME/OneDrive/Documents/shape7/lfsa000b16a_e.shp", options = "ENCODING=WINDOWS-1252") %>% st_transform(crs = 4326)
## Joined data
Dat <- st_join(Bigger_Units, Smaller_Units, join = st_contains, left = TRUE)
Unfortunately, this is returning the following error:
Error in s2_geography_from_wkb(x, oriented = oriented, check = check) :
Evaluation error: Found 3 features with invalid spherical geometry.
[21] Loop 0 is not valid: Edge 6509 has duplicate vertex with edge 6521
[27] Loop 0 is not valid: Edge 49 has duplicate vertex with edge 5931
[49] Loop 9 is not valid: Edge 1402 has duplicate vertex with edge 1574.
I tried researching this error online and came across the following links:
- How to resolve spherical geometry failures when joining spatial data
- How to fix spherical geometry errors caused by conversion from GEOS to s2
- https://gis.stackexchange.com/questions/413584/fix-features-with-invalid-spherical-geometry-polygon-shape-file-for-s2-geometr
But I am unsure as to how I can apply the answers provided in these links to resolve my question.
Can someone please give me a hand with this?
Thank you!