@Thelatemail's answer is the best and easiest solution I've seen in this issue. However, to make it more universal, it is better to delete polygons by name. This is because, depending on the limitations that you give your first call to map (), the polygon name indices may be different.
library(maps) library(mapproj) library(mapdata) mapnames <- map("world2Hires", xlim=c(120, 260), ylim=c(-60, 40), fill=TRUE, plot=FALSE) mapnames2 <- map("world2Hires", xlim=c(100, 200), ylim=c(-20, 60), fill=TRUE, plot=FALSE) mapnames$names[10] [1] "Mali" mapnames2$names[10] [1] "Thailand"
There are 8 countries that intersect with the main meridian: the United Kingdom, France, Spain, Algeria, Mali, Burkina Faso, Ghana and Togo. mapnames$names country names with mapnames$names , you can delete polygons regardless of the initial length:
remove <- c("UK:Great Britain", "France", "Spain", "Algeria", "Mali", "Burkina Faso", "Ghana", "Togo") map("world2Hires", regions=mapnames$names[!(mapnames$names %in% remove)], xlim=c(120, 260), ylim=c(-60, 40), boundary=TRUE, interior=TRUE, fill=TRUE ) map.axes()
You can also use grepl (), but since polygons are called hierarchically, you can delete some sub-polygons of the respective countries. For example, mapnames$names[grepl("UK", mapnames$names)] returns 34 matches.
I would suggest how to edit it, but I do not have privileges yet.