Posts

Showing posts from May, 2022

Introduction to 'R' packages 'mapsf' and 'tmap'

Image
‘R’ Mapping Demo - ‘mapsf’ and ‘tmap’ ‘R’ Mapping Demo - ‘mapsf’ and ‘tmap’ Timothée Giraud 21/02/2022 library(tmap) data("World") tm_shape(World) + tm_polygons("HPI") # install.packages("cartography") library(sf) ## Warning: package 'sf' was built under R version 4.1.3 ## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE library(cartography) ## This project is in maintenance mode. ## Core functionalities of `cartography` can be found in `mapsf`. ## https://riatelab.github.io/mapsf/ # path to the geopackage file embedded in cartography path_to_gpkg <- system.file("gpkg/mtq.gpkg", package="cartography") # import to an sf object mtq <- st_read(dsn = path_to_gpkg, quiet = TRUE) # plot municipalities (only borders are plotted) plot(st_geometry(mtq), col = "grey80", border = "grey") # plot population propSym