In R I want to apply the Mercator-Projection to a SpatialPolygonsDataFrame before plotting it with ggplot.
I dont want to use
ggplot::coord_map() since the map is supposed to be the "canvas" for a network-graph, that i dont want to be mercator-projected aswell.
After using the
sp::spTransform() function I was unable to
broom::tidy() the resulting SpatialPolygonsDataFrame due to "orphaned holes"...
Is the SpatialPolygonsDataFrame provided by
cshapes::cshp() somehow faulty or am I doing the transformation wrong?
cleangeo::clgeo_Clean()-function (Suggested here: Fixing orphaned holes in R) has been computing for at least 3 hours sofar. It doesn't seem to be the ideal approach - even if it turns out to be working...
> library(cshapes) Loading required package: sp Loading required package: maptools Checking rgeos availability: TRUE Loading required package: plyr > library(broom) > wrld <- + cshp(as.Date("2016-01-01")) Warning message: use rgdal::readOGR or sf::st_read > class(wrld)  "SpatialPolygonsDataFrame" attr(,"package")  "sp" > proj4string(wrld)  "+proj=longlat +ellps=WGS84" > wrld <- + spTransform(wrld, CRS("+proj=merc +lon_0=0 +k=1 +x_0=0 + +y_0=0 +ellps=WGS84 +datum=WGS84 + +units=m +no_defs")) > wrld <- + broom::tidy(wrld, region="COWCODE") Error in createPolygonsComment(p) : rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 84