Loads and returns names, ids, iso, and coordinates for world countries, ready to use with mapping
functions and other "map" functions that accept an sf
object.
loadCoordWR(unit = c("country", "nato", "ocde",
"continent", "region", "subregion",
"region_wb", "type_income", "type_economy"),
res = c("low", "hi"), unit_subset = NULL,
matchWith = NULL, dir = NULL, use_cache = TRUE,
use_internet = TRUE, crs = NULL)
the type of world statistical unit
resolution
character vector of unit names to extract
the type of id
local directory in which shape files are stored
a logical value indicating whether to use the cache
a logical value indicating wheter the coordinates are downloaded from https://github.com/dataallaround/geospatial. If FALSE
the maps downloaded during package installation will be used.
coordinate reference system. Look at st_crs
A data.frame object with column indicating names, id, iso and the geometry to map.
Coordinates are download from the Github repo https://github.com/dataallaround/geospatial from world folder https://github.com/dataallaround/geospatial/tree/master/world.
loadCoordIT
, loadCoordEU
, loadCoordUS
, loadCoordDE
, loadCoordUK
# NOT RUN {
WR_coords = loadCoordWR(res = "low")
str(WR_coords, 1)
WR_ocde = loadCoordWR(unit = "ocde",res = "low")
str(WR_ocde, 1)
WR_continent = loadCoordWR(unit = "continent",res = "low")
str(WR_continent, 1)
# }
# NOT RUN {
WR_type_income = loadCoordWR(unit = "type_income",res = "low")
str(WR_type_income, 1)
library(tmap)
tm_shape(WR_coords) + tm_borders()
tm_shape(WR_continent) + tm_borders()
tm_shape(WR_ocde) + tm_borders()
library(mapview)
mapview(WR_coords)
mapview(WR_continent)
mapview(WR_ocde)
coords_wr <- loadCoordWR(unit = "country", unit_subset = c("Italy", "Spain"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab