Description Usage Arguments Details Value Note Author(s) Source Examples
Generates a country or provinces map of Vietnam for a given date and resolution.
1 2 |
date |
either text in the "YYYY-MM-DD" format (for example "2015-01-17" for the 17th of January 2017), or a numeric format of the year (for example 2015). By default "2015-01-01". |
level |
text ("country" or "provinces"). By default "provinces". |
resolution |
text ("low" or "high"). By default "low". |
merge_hanoi |
boolean indicating whether the province of Ha Noi should be merged with the province of Ha Son Binh (before 1992) or the province of Ha Tay (after 1991). |
This function generates a country or provinces map of Vietnam at a given
date, and for a given resolution. Indeed, the delimitations of Vietnamese
provinces have changed through the history with the number of provinces
increasing from 40 in 1979 to 63 in 2008. Most of the events are province
splits and one merging. Changes is provinces boundaries occured on the 1st of
January of 1979, 1990, 1991, 1992, 1997, 2004 and 2008.
The maps generated for a time after 2008 contained different information:
Column Names | Description |
province | name of the province in English |
region | name of the ecologic region in English |
color_ecologic | color associated with the ecologic region |
region_economic | name of the region economic in English |
color_economic | color associated with the economic region |
geometry | list-column with geometries |
Wheras the map generated for a time before 2008, only the columns
"province"
and "geometry"
.
An object of class "sf" and "data.frame".
argument merge_hanoi
makes a difference only for date
before 2008-01-01.
Provinces are plotted in alphabetical order. This is important information to know whenever the user wishes to use these maps to plot covariables.
Marc Choisy
GADM data base from www.gadm.org.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | library(sf)
# BASIC USAGE ---------------------------------------------------------------
# Plotting the map of Vietnamese provinces as of today:
pr <- gadm()
plot(st_geometry(pr))
# other way of plotting
plot(pr["province"]) # by default a color key is given
# The same, with random colors:
plot(st_geometry(pr), col = 1:4)
# Plotting only the country boundaries:
vn <- gadm(level = "country")
plot(st_geometry(vn), col = "grey")
# SF TO SP ------------------------------------------------------------------
# The `pr` object is an object of class `sf` and `data.frame`. For more
# complexe analyses, it a be interresting to work with an object of class
# `SpatialPolygonsDataFrame` from the `sp` package:
sp_vn <- sf::as_Spatial(pr$geometry)
sp::plot(sp_vn)
# MORE COMPLEXE EXAMPLE OF VISUALISATION ------------------------------------
# Visualizing the maps of provinces for all the years where their boundaries
# changed:
vn <- lapply(c(1979, 1990:1992, 1997, 2004, 2008), gadm)
opar <- par(mfrow = c(2, 4))
for(i in vn) plot(st_geometry(i))
par(opar)
# ploting the province of Ha Noi before and after 2008, for 2 values of
# resolution:
vn1_low <- gadm(2007)
vn2_low <- gadm(2008)
vn1_high <- gadm(2007, res = "high")
vn2_high <- gadm(2008, res = "high")
opar <- par(mfrow = c(2, 2))
plot(st_geometry(vn1_low[vn1_low$province %in% c("Ha Noi", "Ha Tay"), ]))
title("2007, low resolution")
plot(st_geometry(vn2_low[vn2_low$province == "Ha Noi", ]))
title("2008, low resolution")
plot(st_geometry(vn1_high[vn1_high$province %in% c("Ha Noi", "Ha Tay"), ]))
title("2007, high resolution")
plot(st_geometry(vn2_high[vn2_high$province == "Ha Noi", ]))
title("2008, high resolution")
par(opar)
plot(st_geometry(vn1_low))
# Showing the same thing on the whole map of Vietnam:
plot(st_geometry(vn1_low))
plot(st_geometry(vn1_high[vn1_high$province %in% c("Ha Noi", "Ha Tay"), ]),
col = c("red","blue"), add=TRUE)
plot(st_geometry(vn2_low))
plot(st_geometry(vn2_high[vn2_high$province == "Ha Noi", ]),
col = "grey", add = TRUE)
# Here we can see that the 2008 delimitation of the province of Ha Noi is
# more than the merging of the provinces of Ha Tay and Ha Noi:
plot(st_geometry(vn2_high[vn2_high$province == "Ha Noi", ]), col = "grey")
plot(st_geometry(vn1_high[vn1_high$province %in% c("Ha Noi", "Ha Tay"), ]),
col = c("red", "blue"), add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.