rplotrworldmap

Remove Antarctica from rworldmap output?


I have the following code, having a working world map output

Map <- joinCountryData2Map(mydf, joinCode = "ISO3",
                                nameJoinColumn = "country")
mapCountryData(Map, nameColumnToPlot="cluster", mapTitle = "", catMethod = "categorical",
               missingCountryCol = gray(.8), colourPalette = customColor, addLegend = F, )

However, I want to exclude Antarctica from the map since it takes up space but doesn't add any extra information. Is there a way to do this? I already googled it, but the advice found there is not applicable to me it seems.


Solution

  • The sp object has a row.names method, since the row names refer to countries, you can easily remove them by subsetting.

    data("countryExData" ,envir=environment(), package="rworldmap")
    
    sPDF <- joinCountryData2Map(countryExData, joinCode="ISO3", nameJoinColumn="ISO3V10")
    
    sPDF <- sPDF[row.names(sPDF) != 'Antarctica', ]
    
    mapCountryData(sPDF, nameColumnToPlot="BIODIVERSITY")
    

    enter image description here