Skip to contents

Loads and returns names, id, and coordinates for United Kingdom statistical unit, to use with mapping functions and other "map" functions that accept an sf object.

Usage

loadCoordUK(unit = c("country", "county"), 
            year = c("2020", "2019"), scale = c("500", "20"), 
            unit_subset = NULL, matchWith = NULL, dir = NULL, 
            use_cache = TRUE, use_internet = TRUE, crs = NULL)

Arguments

unit

the type of Italian statistical unit to link

year

year of the analysis

scale

the scale of the map

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 UK folder https://github.com/mappinguniverse/geospatial/tree/master/UK.

If unit is not specified, country borders are loaded.

Value

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

Author

Alessio Serafini

Examples


UK_coords = loadCoordUK(unit = "country", year = "2020")
str(UK_coords)
#> Classes ‘sf’, ‘UK’ and 'data.frame':	4 obs. of  3 variables:
#>  $ country : chr  "england" "northern ireland" "scotland" "wales"
#>  $ code    : chr  "E92000001" "N92000002" "S92000003" "W92000004"
#>  $ geometry:sfc_MULTIPOLYGON of length 4; first list element: List of 35
#>   ..$ :List of 1
#>   .. ..$ : num [1:2082, 1:2] -2.09 -2.09 -2.1 -2.11 -2.12 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:48, 1:2] -1.31 -1.35 -1.4 -1.38 -1.41 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:20, 1:2] 0.824 0.79 0.749 0.735 0.747 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:11, 1:2] 0.957 0.874 0.867 0.838 0.84 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:15, 1:2] -1.08 -1.08 -1.1 -1.09 -1.09 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:9, 1:2] 1 0.999 0.966 0.943 0.925 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:16, 1:2] -0.968 -0.99 -0.983 -0.995 -1.025 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:19, 1:2] -3.25 -3.27 -3.25 -3.28 -3.27 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] -1.8 -1.85 -1.85 -1.82 -1.8 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:12, 1:2] -6.28 -6.3 -6.31 -6.31 -6.33 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] -4.68 -4.68 -4.67 -4.65 -4.68 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 0.83 0.808 0.823 0.837 0.83 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] -6.29 -6.29 -6.3 -6.28 -6.26 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] -6.35 -6.33 -6.32 -6.35 49.97 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 1.23 1.23 1.24 1.26 1.23 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 0.666 0.673 0.694 0.683 0.666 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] -6.36 -6.36 -6.35 -6.35 -6.36 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] -6.35 -6.35 -6.34 -6.34 -6.33 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:17, 1:2] 0.658 0.686 0.682 0.685 0.697 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] -1.97 -1.99 -1.96 -1.96 -1.97 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 0.77 0.755 0.77 0.788 0.77 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.708 0.726 0.721 0.708 51.72 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 0.867 0.855 0.868 0.872 0.867 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.66 0.688 0.679 0.66 51.418 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] -0.554 -0.536 -0.521 -0.554 53.69 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 0.894 0.886 0.876 0.887 0.88 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 0.624 0.624 0.609 0.627 0.627 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 1.22 1.22 1.21 1.22 1.22 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.564 0.561 0.583 0.564 51.408 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.597 0.615 0.608 0.597 51.396 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.833 0.856 0.838 0.833 51.769 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 1.23 1.24 1.23 1.23 51.89 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 1.26 1.26 1.26 1.26 51.87 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] 0.902 0.892 0.912 0.902 52.966 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:4, 1:2] -1.1 -1.1 -1.09 -1.1 50.82 ...
#>   ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
#>  - attr(*, "sf_column")= chr "geometry"
#>  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
#>   ..- attr(*, "names")= chr [1:2] "country" "code"
#>  - attr(*, "unit")= chr "country"
#>  - attr(*, "colID")= chr "country"


# \donttest{

## Load subset

coords_uk <- loadCoordUK(unit = "county", unit_subset = "england", matchWith = "country")
coords_uk <- loadCoordUK(unit = "county", unit_subset = "hartlepool", matchWith = "county")

# }