Skip to contents

Loads and returns names, ids, and coordinates for Italian statistical unit, ready to use with mapping functions and other "map" functions that accept an sf object.

Usage

loadCoordIT(unit = c("none","ripartizione", "regione", "provincia","comune"),
            year = c("2021","2020", "2019", "2018", "2017"),
            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

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

unit="none" (default) indicates that the border of Italy is returned.

Value

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

Author

Alessio Serafini

Examples


IT_coords = loadCoordIT(unit = "regione", year = "2020")
str(IT_coords)
#> Classes ‘sf’, ‘IT’ and 'data.frame':	20 obs. of  5 variables:
#>  $ ripartizione     : chr  "Nord-ovest" "Nord-ovest" "Nord-ovest" "Nord-est" ...
#>  $ code_ripartizione: int  1 1 1 2 2 2 1 2 3 3 ...
#>  $ code_regione     : int  1 2 3 5 4 6 7 8 9 10 ...
#>  $ regione          : chr  "Piemonte" "Valle d'Aosta/Vallée d'Aoste" "Lombardia" "Veneto" ...
#>  $ geometry         :sfc_MULTIPOLYGON of length 20; first list element: List of 1
#>   ..$ :List of 3
#>   .. ..$ : num [1:4663, 1:2] 8.45 8.45 8.45 8.45 8.44 ...
#>   .. ..$ : num [1:4, 1:2] 8.71 8.71 8.7 8.71 45.02 ...
#>   .. ..$ : num [1:4, 1:2] 8.82 8.82 8.81 8.82 45.02 ...
#>   ..- 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
#>   ..- attr(*, "names")= chr [1:4] "ripartizione" "code_ripartizione" "code_regione" "regione"
#>  - attr(*, "unit")= chr "regione"
#>  - attr(*, "colID")= chr "regione"


# \donttest{
## Italy

IT_coords = loadCoordIT()
str(IT_coords)
#> Classes ‘sf’, ‘IT’ and 'data.frame':	1 obs. of  7 variables:
#>  $ id       : chr "IT"
#>  $ CNTR_CODE: chr "IT"
#>  $ NUTS_NAME: chr "ITALIA"
#>  $ LEVL_CODE: int 0
#>  $ FID      : chr "IT"
#>  $ NUTS_ID  : chr "IT"
#>  $ geometry :sfc_MULTIPOLYGON of length 1; first list element: List of 68
#>   ..$ :List of 3
#>   .. ..$ : num [1:1079, 1:2] 12.4 12.4 12.3 12.3 12.3 ...
#>   .. ..$ : num [1:14, 1:2] 12.4 12.5 12.5 12.5 12.5 ...
#>   .. ..$ : num [1:5, 1:2] 12.5 12.5 12.4 12.4 12.5 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:174, 1:2] 15.3 15.3 15.5 15.6 15.6 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:206, 1:2] 9.68 9.69 9.64 9.62 9.58 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:36, 1:2] 10.4 10.4 10.4 10.3 10.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:14, 1:2] 8.36 8.36 8.36 8.35 8.36 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:20, 1:2] 12 12 11.9 11.9 11.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:34, 1:2] 8.34 8.35 8.34 8.32 8.33 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:21, 1:2] 8.3 8.27 8.26 8.24 8.23 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:21, 1:2] 13.9 13.9 13.9 13.9 13.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:15, 1:2] 15 15 15 15 15 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:13, 1:2] 14.9 14.8 14.8 14.8 14.8 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:16, 1:2] 10.9 10.9 10.9 10.9 10.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:18, 1:2] 15 15 15 15 14.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:12, 1:2] 9.84 9.85 9.84 9.84 9.83 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:17, 1:2] 9.42 9.41 9.4 9.4 9.39 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:15, 1:2] 12.3 12.3 12.3 12.3 12.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:14, 1:2] 12.5 12.5 12.5 12.6 12.6 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:19, 1:2] 9.48 9.46 9.46 9.45 9.45 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 15.2 15.2 15.2 15.2 15.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:10, 1:2] 12.1 12.1 12 12 12 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:10, 1:2] 10.3 10.3 10.3 10.3 10.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:11, 1:2] 14.2 14.2 14.2 14.2 14.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:12, 1:2] 10.1 10.1 10.1 10.1 10 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:10, 1:2] 12.3 12.3 12.3 12.3 12.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 14.6 14.6 14.5 14.6 14.6 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 13.2 13.2 13.2 13.2 13.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:12, 1:2] 12.4 12.4 12.4 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:13, 1:2] 9.33 9.34 9.35 9.34 9.35 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:10, 1:2] 13 13 13 13 12.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 12.3 12.3 12.3 12.3 12.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:8, 1:2] 9.74 9.74 9.73 9.69 9.68 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 12.9 12.9 12.8 12.9 12.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 14.3 14.3 14.3 14.4 14.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:10, 1:2] 12.5 12.4 12.5 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 13.3 13.3 13.3 13.3 13.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 9.36 9.35 9.34 9.33 9.34 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 9.74 9.72 9.71 9.74 9.74 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 12.4 12.4 12.4 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 13.4 13.4 13.4 13.4 13.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 15.1 15.1 15.1 15.1 15.1 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:7, 1:2] 14 14 14 14 14 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 9.42 9.41 9.4 9.41 9.42 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 8.98 8.98 8.97 8.96 8.98 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 9.89 9.89 9.9 9.91 9.89 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 12.3 12.3 12.3 12.3 12.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 15.5 15.5 15.5 15.5 15.5 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 12.4 12.4 12.4 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 9.16 9.15 9.14 9.15 9.16 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 11.1 11.1 11.1 11.1 11.1 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 13 13 13 13 13 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 12.4 12.4 12.4 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 9.53 9.52 9.54 9.54 9.53 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 13.4 13.4 13.4 13.4 13.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 12.4 12.3 12.3 12.4 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 15.5 15.5 15.5 15.5 15.5 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 8.23 8.22 8.21 8.22 8.23 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 12.9 12.9 12.8 12.9 12.9 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 13.1 13.1 13 13 13.1 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 13.4 13.4 13.4 13.4 13.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 10.1 10.1 10.1 10.1 10.1 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 8.44 8.43 8.43 8.44 8.44 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 13.2 13.2 13.2 13.2 13.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 12.3 12.3 12.3 12.3 12.3 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 15.2 15.2 15.2 15.2 15.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 17.2 17.1 17.2 17.2 17.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 12.4 12.3 12.3 12.3 12.4 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:6, 1:2] 13.2 13.2 13.2 13.2 13.2 ...
#>   ..$ :List of 1
#>   .. ..$ : num [1:5, 1:2] 13.3 13.3 13.3 13.3 13.3 ...
#>   ..- 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
#>   ..- attr(*, "names")= chr [1:6] "id" "CNTR_CODE" "NUTS_NAME" "LEVL_CODE" ...
#>  - attr(*, "unit")= chr "none"
#>  - attr(*, "colID")= chr "none"


coords_it<- loadCoordIT(unit = "regione", unit_subset = c(5, 10), matchWith = "number")
str(coords_it)
#> Classes ‘sf’, ‘IT’ and 'data.frame':	2 obs. of  5 variables:
#>  $ ripartizione     : chr  "Nord-est" "Centro"
#>  $ code_ripartizione: int  2 3
#>  $ code_regione     : int  5 10
#>  $ regione          : chr  "Veneto" "Umbria"
#>  $ geometry         :sfc_MULTIPOLYGON of length 2; first list element: List of 1
#>   ..$ :List of 1
#>   .. ..$ : num [1:3683, 1:2] 12.5 12.5 12.5 12.5 12.5 ...
#>   ..- 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
#>   ..- attr(*, "names")= chr [1:4] "ripartizione" "code_ripartizione" "code_regione" "regione"
#>  - attr(*, "unit")= chr "regione"
#>  - attr(*, "colID")= chr "regione"


# }