This package contains the polygons of Vietnam and its provinces at different points in time since 1979, reflecting the changes in the administrative divisions along the history of Vietnam.
You can install gadmVN
from GitHub with:
```{r eval = FALSE}
devtools::install_github("choisy/gadmVN", build_vignettes = TRUE)
Once installed, you can load the package:
```{r}
library(gadmVN)
SpatialPolygonsDataFrame
can be retrieved thanks to the gadm
function. The
first argument is the date at which we want the map (either a text in the
"YYYY-MM-DD" format or a 4-digit numeric format of the year). The second
argument specifies the level we are interested in (either "provinces" or
"country"), the third argument is the level of resolution we want (either "low"
or "high") and the last argument tells whether we want the province of Ha Noi
and Ha Son Binh to be merged. This latter argument makes a difference only for
date before 1992-01-01.
The map of the provinces in 1992
pr <- gadm(1992)
Maping 4 categories of provinces according to latitude:
latitudes <- coordinates(pr)[, 2]
breaks <- seq(min(latitudes), max(latitudes), le = 5)
palette <- c("red", "blue", "green", "orange")
colors <- palette[as.numeric(cut(latitudes, breaks, include = TRUE))]
plot(pr, col = colors)
Plotting the 8 regions of Vietnam:
provinces <- gadm()
plot(provinces, col = provinces$color)
leg <- unique(provinces@data[, c("region", "color")])
legend("topright", legend = leg$region, fill = leg$color, bty = "n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.