(This article was first published on

**Data Analysis and Visualization in R**, and kindly contributed to R-bloggers)This blog demonstrates how to produce political/provincial boundary map (below) using R maptools and raster packages.

## Load required packages

library(maptools)

library(raster)

library(raster)

## Download data from gadm.org

adm <- getData(‘GADM’, country=’PHL’, level=2)

mar<-(adm[adm$NAME_1==”Marinduque”,])plot(mar, bg=”dodgerblue”, axes=T)

adm <- getData(‘GADM’, country=’PHL’, level=2)

mar<-(adm[adm$NAME_1==”Marinduque”,])plot(mar, bg=”dodgerblue”, axes=T)

##Plot downloaded data

plot(mar, lwd=10, border=”skyblue”, add=T)

plot(mar,col=”green4″, add=T)

grid()

box()

invisible(text(getSpPPolygonsLabptSlots(mar), labels=as.character(mar$NAME_2), cex=1.1, col=”white”, font=2))

mtext(side=3, line=1, “Provincial Map of Marinduque”, cex=2)

mtext(side=1, “Longitude”, line=2.5, cex=1.1)

mtext(side=2, “Latitude”, line=2.5, cex=1.1)

text(122.08,13.22, “Projection: Geographic\nCoordinate System: WGS 1984\nData Source: GADM.org\nCreated by: ARSsalvacion”, adj=c(0,0), cex=0.7, col=”grey20″)

plot(mar, lwd=10, border=”skyblue”, add=T)

plot(mar,col=”green4″, add=T)

grid()

box()

invisible(text(getSpPPolygonsLabptSlots(mar), labels=as.character(mar$NAME_2), cex=1.1, col=”white”, font=2))

mtext(side=3, line=1, “Provincial Map of Marinduque”, cex=2)

mtext(side=1, “Longitude”, line=2.5, cex=1.1)

mtext(side=2, “Latitude”, line=2.5, cex=1.1)

text(122.08,13.22, “Projection: Geographic\nCoordinate System: WGS 1984\nData Source: GADM.org\nCreated by: ARSsalvacion”, adj=c(0,0), cex=0.7, col=”grey20″)

To

**leave a comment**for the author, please follow the link and comment on their blog:**Data Analysis and Visualization in R**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...