Closed rsbivand closed 1 year ago
This updates the previous fix by closing Western Sahara (polygon 137) in coarse countries. The abbreviiated code is:
sPDF <- rworldmap::getMap() library(sp) sP <- geometry(sPDF) psP <- slot(sP, "polygons") res <- lapply(psP, function(x) {lapply(slot(x, "Polygons"), function(y) {crds=slot(y, "coords"); isTRUE(all.equal(crds[1,], crds[nrow(crds),]))})}) all(sapply(res, function(x) all(unlist(x)))) which(!sapply(res, function(x) all(unlist(x)))) sPDF[137, "NAME"] crds <- sP@polygons[[137]]@Polygons[[1]]@coords crds[1,] crds[27,] crds1 <- rbind(crds, crds[1,]) sP@polygons[[137]]@Polygons[[1]]@coords <- crds1 res <- lapply(sP@polygons, function(x) {lapply(slot(x, "Polygons"), function(y) {crds=slot(y, "coords"); isTRUE(all.equal(crds[1,], crds[nrow(crds),]))})}) all(sapply(res, function(x) all(unlist(x)))) sPDF@polygons <- sP@polygons xx <- sf::st_as_sf(sPDF) countriesCoarse <- sPDF save(countriesCoarse, file="data/countriesCoarse.rda", version=2)
This may be needed if any of the other saved polygon data objects also has the non-closed polygon problem. Update: high, low and coarse-less-islands all appear OK.
With these patches, the passing instrumented check log is: 00check.log
This updates the previous fix by closing Western Sahara (polygon 137) in coarse countries. The abbreviiated code is:
This may be needed if any of the other saved polygon data objects also has the non-closed polygon problem. Update: high, low and coarse-less-islands all appear OK.