I use the rworldmap
package with WorldBank Data and I enjoy it. I want to plot maps for Iran, with data related to each province. What are the steps to do that? I know we can plot maps like that in R
for some countries like US but not for all countries.
You can combine rworldmap
with the great suggestion from @jazzurro of using raster
to get GADM boundaries.
I suspect your main difficulty might be getting the province names to match between your data and the map.
The example below, uses defaults that you can change and just gives a different colour for each province.
library(raster)
library(rworldmap)
## 1 Get map of provinces (level 1 admin regions)
iranLevel1<- raster::getData("GADM", country = "Iran", level = 1)
## 2 join your [data] onto the map by specifying the join column in each
## this will report on any mis-matches between province names
#iranLevel1 <- rworldmap::joinData2Map([data],nameMap="iranLevel1",nameJoinIDMap="NAME_1",nameJoinColumnData=[insert])
## 3 plot map (change NAME_1 to the data you want to plot)
rworldmap::mapPolys(iranLevel1, nameColumnToPlot="NAME_1", addLegend=FALSE)
## 4 add text labels for provinces
text(iranLevel1, label="NAME_1", cex=0.7)
Note that joinData2Map()
, mapPolys()
are more generic equivalents of joinCountryData2Map()
, mapCountryData()
.
Another way of doing this would be to use the choroplethr
package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With