项目作者: riatelab

项目描述 :
Thematic Cartography for R
高级语言: R
项目地址: git://github.com/riatelab/cartography.git
创建时间: 2015-06-11T08:27:11Z
项目社区:https://github.com/riatelab/cartography

开源协议:

下载


" class="reference-link">cartography


R-CMD-check
Codecov test coverage
DOI

Consider mapsf

There are no plans for new features or enhancements in cartography.
Basic maintenance and support will continue indefinitely.
Existing projects that use cartography can safely continue to use cartography.
The mapsf R package is the successor of cartography and it is friendlier, lighter and more robust.
See mapsf vignette or this blog post to migrate from cartography to mapsf.

Create and integrate maps in your R workflow!

This package helps to design cartographic representations such as proportional symbols, choropleth, typology, flows or discontinuities maps. It also offers several features that improve the graphic presentation of maps, for instance, map palettes, layout elements (scale, north arrow, title…), labels or legends.

Demo

The following script creates a map of symbols that are proportional to values of a
first variable and colored to reflect the classification of a second variable.

  1. library(sf)
  2. library(cartography)
  3. # path to the geopackage file embedded in cartography
  4. path_to_file <- system.file("gpkg/mtq.gpkg", package="cartography")
  5. # import to an sf object
  6. mtq <- st_read(dsn = path_to_file, quiet = TRUE)
  7. ########## Draft Map
  8. # Plot the municipalities
  9. plot(st_geometry(mtq))
  10. # Plot symbols with choropleth coloration (population & median income)
  11. propSymbolsChoroLayer(x = mtq, var = "POP", var2 = "MED")
  12. # Add a layout
  13. title(main = "Population & Wealth in Martinique, 2015",
  14. sub = "Sources: Insee and IGN - 2018")

  1. ########## Final Map
  2. # Set figure margins
  3. opar <- par(mar = c(0,0,1.2,0))
  4. # Plot the municipalities
  5. plot(st_geometry(mtq), col="darkseagreen3", border="darkseagreen4",
  6. bg = "lightblue1", lwd = 0.5)
  7. # Plot symbols with choropleth coloration
  8. propSymbolsChoroLayer(x = mtq, var = "POP", inches = 0.4, border = "grey50",
  9. lwd = 1, legend.var.pos = "topright",
  10. legend.var.title.txt = "Population",
  11. var2 = "MED", method = "equal", nclass = 4,
  12. col = carto.pal(pal1 = "sand.pal", n1 = 4),
  13. legend.var2.values.rnd = -2, legend.var2.pos = "left",
  14. legend.var2.title.txt = "Median Income\n(in euros)")
  15. # Plot a layout
  16. layoutLayer(title="Population & Wealth in Martinique, 2015",
  17. author = "cartography 2.1.3",
  18. sources = "Sources: Insee and IGN - 2018",
  19. scale = 5, tabtitle = TRUE, frame = FALSE)
  20. # Plot a north arrow
  21. north(pos = "topleft")
  22. # restore graphics parameters
  23. par(opar)

Installation

  • Development version on GitHub

    1. remotes::install_github("riatelab/cartography")
  • Stable version on CRAN

    1. install.packages("cartography")

Alternatives

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here.


To cite package cartography in publications use one of these: