Skip to contents

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.

Usage

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)

Arguments

unit

the type of world statistical unit

res

resolution

unit_subset

character vector of unit names to extract

matchWith

the type of id

dir

local directory in which shape files are stored

use_cache

a logical value indicating whether to use the cache

use_internet

a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If FALSE the maps downloaded during package installation will be used.

crs

coordinate reference system. Look at st_crs

Details

Coordinates are download from the Github repo https://github.com/mappinguniverse/geospatial from world folder https://github.com/mappinguniverse/geospatial/tree/master/world.

Value

A data.frame object with column indicating names, id, iso and the geometry to map.

Author

Alessio Serafini

Examples



WR_coords = loadCoordWR(res = "low")
str(WR_coords, 1)
#> Classes ‘sf’, ‘WR’ and 'data.frame':	248 obs. of  20 variables:
#>  $ country     : chr  "Indonesia" "Malaysia" "Chile" "Bolivia" ...
#>  $ name_formal : chr  "Republic of Indonesia" "Malaysia" "Republic of Chile" "Plurinational State of Bolivia" ...
#>  $ name_wb     : chr  "Indonesia" "Malaysia" "Chile" "Bolivia" ...
#>  $ iso2        : chr  "ID" "MY" "CL" "BO" ...
#>  $ iso3        : chr  "IDN" "MYS" "CHL" "BOL" ...
#>  $ iso3_eh     : chr  "IDN" "MYS" "CHL" "BOL" ...
#>  $ iso3_numeric: chr  "360" "458" "152" "068" ...
#>  $ iso3_un     : chr  "360" "458" "152" "068" ...
#>  $ iso2_wb     : chr  "ID" "MY" "CL" "BO" ...
#>  $ iso3_wb     : chr  "IDN" "MYS" "CHL" "BOL" ...
#>  $ continent   : chr  "Asia" "Asia" "South America" "South America" ...
#>  $ region      : chr  "Asia" "Asia" "Americas" "Americas" ...
#>  $ subregion   : chr  "South-Eastern Asia" "South-Eastern Asia" "South America" "South America" ...
#>  $ region_wb   : chr  "East Asia & Pacific" "East Asia & Pacific" "Latin America & Caribbean" "Latin America & Caribbean" ...
#>  $ type        : chr  "Sovereign country" "Sovereign country" "Sovereign country" "Sovereign country" ...
#>  $ type_economy: chr  "Emerging" "Developing" "Emerging" "Emerging" ...
#>  $ type_income : chr  "Lower middle income" "Upper middle income" "Upper middle income" "Lower middle income" ...
#>  $ nato        : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
#>  $ ocde        : logi  FALSE FALSE TRUE FALSE FALSE FALSE ...
#>  $ geometry    :sfc_MULTIPOLYGON of length 248; first list element: List of 178
#>   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
#>  - attr(*, "sf_column")= chr "geometry"
#>  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
#>   ..- attr(*, "names")= chr [1:19] "country" "name_formal" "name_wb" "iso2" ...
#>  - attr(*, "unit")= chr "country"
#>  - attr(*, "colID")= chr "country"


WR_ocde = loadCoordWR(unit = "ocde",res = "low")
str(WR_ocde, 1)
#> Classes ‘sf’, ‘WR’ and 'data.frame':	41 obs. of  19 variables:
#>  $ country     : chr  "Chile" "Israel" "France" "South Korea" ...
#>  $ name_formal : chr  "Republic of Chile" "State of Israel" "French Republic" "Republic of Korea" ...
#>  $ name_wb     : chr  "Chile" "Israel" "France" "Korea, Republic of" ...
#>  $ iso2        : chr  "CL" "IL" "FR" "KR" ...
#>  $ iso3        : chr  "CHL" "ISR" "FRA" "KOR" ...
#>  $ iso3_eh     : chr  "CHL" "ISR" "FRA" "KOR" ...
#>  $ iso3_numeric: chr  "152" "376" "250" "410" ...
#>  $ iso3_un     : chr  "152" "376" "250" "410" ...
#>  $ iso2_wb     : chr  "CL" "IL" "FR" "KR" ...
#>  $ iso3_wb     : chr  "CHL" "ISR" "FRA" "KOR" ...
#>  $ continent   : chr  "South America" "Asia" "Europe" "Asia" ...
#>  $ region      : chr  "Americas" "Asia" "Europe" "Asia" ...
#>  $ subregion   : chr  "South America" "Western Asia" "Western Europe" "Eastern Asia" ...
#>  $ region_wb   : chr  "Latin America & Caribbean" "Middle East & North Africa" "Europe & Central Asia" "East Asia & Pacific" ...
#>  $ type        : chr  "Sovereign country" "Country" "Country" "Sovereign country" ...
#>  $ type_economy: chr  "Emerging" "Developed" "Developed" "Emerging" ...
#>  $ type_income : chr  "Upper middle income" "High income" "High income" "High income" ...
#>  $ nato        : logi  FALSE FALSE TRUE FALSE TRUE TRUE ...
#>  $ geometry    :sfc_MULTIPOLYGON of length 41; first list element: List of 41
#>   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
#>  - attr(*, "sf_column")= chr "geometry"
#>  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
#>   ..- attr(*, "names")= chr [1:18] "country" "name_formal" "name_wb" "iso2" ...
#>  - attr(*, "unit")= chr "ocde"
#>  - attr(*, "colID")= chr "ocde"

WR_continent = loadCoordWR(unit = "continent",res = "low")
str(WR_continent, 1)
#> Classes ‘sf’, ‘WR’ and 'data.frame':	7 obs. of  2 variables:
#>  $ continent: chr  "Africa" "Asia" "Europe" "North America" ...
#>  $ geometry :sfc_MULTIPOLYGON of length 7; first list element: List of 50
#>   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
#>  - attr(*, "sf_column")= chr "geometry"
#>  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA
#>   ..- attr(*, "names")= chr "continent"
#>  - attr(*, "unit")= chr "continent"
#>  - attr(*, "colID")= chr "continent"