hypertidy / toposhop

2 stars 0 forks source link

non-closed rings #3

Open mdsumner opened 7 years ago

mdsumner commented 7 years ago

In sp we could do it by re-building every ring with Polygon():

library("rworldmap")
map_coarse <- getMap(resolution = "coarse")

## recomposing with Polygon() will fix any that need it 
map_partly_fixed <- SpatialPolygonsDataFrame(SpatialPolygons(lapply(geometry(map_coarse)@polygons, function(a) Polygons(lapply(a@Polygons, function(b) Polygon(b@coords)), a@ID)), 
                proj4string = CRS(proj4string(map_coarse))), map_coarse@data, match.ID = FALSE)

rgeos::gIsValid(map_partly_fixed)

That is then still overlapping itself, see here: https://github.com/mtennekes/tmap/issues/96