A new version of the cartography
package (v2.4.0) has arrived on CRAN.
New Features
waffleLayer()
plots a “waffle map”. This kind of representation allows to plot several quantities on the same map.
ghostLayer()
is a short function that plot an invisible layer with the extent of a spatial object. This function is useful to initiate a map with a specific extent.
library(sf) library(cartography) mtq <- st_read(system.file("gpkg/mtq.gpkg",
package="cartography")) target <- mtq[30, ] ghostLayer(target) plot(st_geometry(mtq), col = "gold2", add = TRUE)
hatchedLayer()
plots a hatched layer, several patterns are available.getPngLayer()
import a PNG image and cut it using the shape of a spatial object.wordcloudLayer()
plots a word cloud adjusted to an sf object.
These 3 functions are well described by their creator, Diego Hernangómez, on his blog.
Enhancements
getTiles()
gets map tiles from various tile servers.
- The function has gained caching capacities (through
cachedir
andforceDownload
arguments). Users can now cache tiles in a folder and reuse them across R sessions. - More than 50 tile servers have been included and other can be added by users.
- It is possible to use Thunderforest tiles with an API key.
The barscale()
function plots a scale bar on a map, a new unit
argument has been added to plot the scale bar in meters, kilometers or miles.
Under the Hood
cartography
does not use rosm
anymore to import map tiles. The package is working great but its maintainer, Dewey Dunnington, suggests that it will not evolve much and that other package will appear to replace it. Thus we have decided to use slippymath
and internal code to download tiles. A (positive) side effect of this replacement is a decrease in the indirect dependancies of cartography
.
cartography
appears to be robust to the changes introduced by the last sf
version (v0.9). This version takes into account the new representation of coordinate reference systems proposed by GDAL and PROJ. More information on this here.
OpenEdition vous propose de citer ce billet de la manière suivante :
Timothée Giraud (3 avril 2020). New version of cartography. R Géomatique. Consulté le 10 octobre 2024 à l’adresse https://doi.org/10.58079/tp4l