Closed dieghernan closed 3 years ago
library(giscoR)
#> Warning: package 'giscoR' was built under R version 4.0.5
library(tmap)
#> Warning: package 'tmap' was built under R version 4.0.4
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
Italy <- gisco_get_nuts(year=2021, nuts_level = 1, country = "Italy")
st_geometry_type(Italy)
#> [1] POLYGON MULTIPOLYGON MULTIPOLYGON POLYGON MULTIPOLYGON
#> 18 Levels: GEOMETRY POINT LINESTRING POLYGON MULTIPOINT ... TRIANGLE
tm_shape(Italy) +
tm_polygons() +
tm_text("NAME_LATN")
# See how to solve this
Italy2 <- st_cast(Italy,"MULTIPOLYGON")
tm_shape(Italy2) +
tm_polygons() +
tm_text("NAME_LATN")
sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19041)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
#> [3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
#> [5] LC_TIME=Spanish_Spain.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] sf_0.9-8 tmap_3.3-1 giscoR_0.2.2
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.6 countrycode_1.2.0 lattice_0.20-41 png_0.1-7
#> [5] class_7.3-18 assertthat_0.2.1 digest_0.6.27 utf8_1.2.1
#> [9] R6_2.5.0 backports_1.2.1 reprex_2.0.0 evaluate_0.14
#> [13] e1071_1.7-6 highr_0.8 pillar_1.5.1 rlang_0.4.10
#> [17] raster_3.4-5 rmarkdown_2.7 styler_1.4.1 stringr_1.4.0
#> [21] htmlwidgets_1.5.3 proxy_0.4-25 compiler_4.0.3 xfun_0.22
#> [25] pkgconfig_2.0.3 tmaptools_3.1-1 base64enc_0.1-3 htmltools_0.5.1.1
#> [29] tidyselect_1.1.0 tibble_3.1.0 codetools_0.2-18 XML_3.99-0.6
#> [33] fansi_0.4.2 viridisLite_0.3.0 crayon_1.4.1.9000 dplyr_1.0.5
#> [37] withr_2.4.1 grid_4.0.3 lwgeom_0.2-6 lifecycle_1.0.0
#> [41] DBI_1.1.1 magrittr_2.0.1 units_0.7-1 KernSmooth_2.23-18
#> [45] stringi_1.5.3 debugme_1.1.0 fs_1.5.0 leafsync_0.1.0
#> [49] leaflet_2.0.4.1 sp_1.4-5 ellipsis_0.3.1 generics_0.1.0
#> [53] vctrs_0.3.7 geojsonsf_2.0.1 RColorBrewer_1.1-2 tools_4.0.3
#> [57] dichromat_2.0-0 leafem_0.1.3 glue_1.4.2 purrr_0.3.4
#> [61] crosstalk_1.1.1 abind_1.4-5 parallel_4.0.3 yaml_2.2.1
#> [65] stars_0.5-2 classInt_0.4-3 knitr_1.31
Created on 2021-04-10 by the reprex package (v2.0.0)
No need to fix anything, just use point.per
option:
library(giscoR)
#> Warning: package 'giscoR' was built under R version 4.0.5
library(tmap)
#> Warning: package 'tmap' was built under R version 4.0.4
Italy <- gisco_get_nuts(year=2021, nuts_level = 1, country = "Italy")
tm_shape(Italy, point.per = "feature") +
tm_polygons() +
tm_text("NAME_LATN")
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19041)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
#> [3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
#> [5] LC_TIME=Spanish_Spain.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] sf_0.9-8 tmap_3.3-1 giscoR_0.2.2
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.6 countrycode_1.2.0 lattice_0.20-41 png_0.1-7
#> [5] class_7.3-18 assertthat_0.2.1 digest_0.6.27 utf8_1.2.1
#> [9] R6_2.5.0 backports_1.2.1 reprex_2.0.0 evaluate_0.14
#> [13] e1071_1.7-6 highr_0.8 pillar_1.5.1 rlang_0.4.10
#> [17] raster_3.4-5 rmarkdown_2.7 styler_1.4.1 stringr_1.4.0
#> [21] htmlwidgets_1.5.3 proxy_0.4-25 compiler_4.0.3 xfun_0.22
#> [25] pkgconfig_2.0.3 tmaptools_3.1-1 base64enc_0.1-3 htmltools_0.5.1.1
#> [29] tidyselect_1.1.0 tibble_3.1.0 codetools_0.2-18 XML_3.99-0.6
#> [33] fansi_0.4.2 viridisLite_0.3.0 crayon_1.4.1.9000 dplyr_1.0.5
#> [37] withr_2.4.1 grid_4.0.3 lwgeom_0.2-6 lifecycle_1.0.0
#> [41] DBI_1.1.1 magrittr_2.0.1 units_0.7-1 KernSmooth_2.23-18
#> [45] stringi_1.5.3 debugme_1.1.0 fs_1.5.0 leafsync_0.1.0
#> [49] leaflet_2.0.4.1 sp_1.4-5 ellipsis_0.3.1 generics_0.1.0
#> [53] vctrs_0.3.7 geojsonsf_2.0.1 RColorBrewer_1.1-2 tools_4.0.3
#> [57] dichromat_2.0-0 leafem_0.1.3 glue_1.4.2 purrr_0.3.4
#> [61] crosstalk_1.1.1 abind_1.4-5 parallel_4.0.3 yaml_2.2.1
#> [65] stars_0.5-2 classInt_0.4-3 knitr_1.31
Created on 2021-04-11 by the reprex package (v2.0.0)
Added example on README
See: