cartogram

r package for cartogram creation

https://github.com/sjewo/cartogram

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    2 of 6 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

rstats

Keywords from Contributors

thematic-maps geos cartography geography gdal proj choropleth-maps visualisation rspatial
Last synced: 7 months ago · JSON representation

Repository

r package for cartogram creation

Basic Info
Statistics
  • Stars: 150
  • Watchers: 7
  • Forks: 15
  • Open Issues: 5
  • Releases: 2
Topics
rstats
Created over 9 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog

README.Rmd

---
title: "cartogram: Create Cartograms with R"
output:
  github_document:
    fig_width: 4
    fig_height: 3.5
---


[![CRAN status](https://www.r-pkg.org/badges/version/cartogram)](https://cran.r-project.org/package=cartogram)
[![R-CMD-check](https://github.com/sjewo/cartogram/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sjewo/cartogram/actions/workflows/R-CMD-check.yaml)
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/cartogram)](https://cran.r-project.org/package=cartogram)


```{r, echo=F}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)
```

`cartogram` is an R package that implements methods for generating continuous area cartograms (based on the rubber sheet distortion algorithm by Dougenik et al., 1985), non-contiguous area cartograms (Olson, 1976), and non-overlapping circles cartograms (Dorling et al., 1996).

## Installation

You can install the **cartogram** package from CRAN as follows:

```{r, eval=FALSE}
install.packages("cartogram")
```

To upgrade to the latest development version of `cartogram`, install the package `remotes` and run the following command:

```{r, eval=FALSE}
remotes::install_github("sjewo/cartogram")
```

## Examples

### Continuous Area Cartogram

```{r cont, fig.asp = 1.2}
library(cartogram)
library(sf)
library(tmap)

data("World")

# Keep only the African continent
afr <- World[World$continent == "Africa", ]

# Project the map
afr <- st_transform(afr, 3395)

# Construct continuous area cartogram
afr_cont <- cartogram_cont(afr, "pop_est", itermax = 5)

# Plot the cartogram
tm_shape(afr_cont) +
  tm_polygons("pop_est",
              fill.scale = tm_scale_intervals(style = "jenks")) +
  tm_layout(frame = FALSE,
            legend.position = c("left", "bottom"))
```

### Non-contiguous Area Cartogram

```{r ncont, fig.asp = 1.2}
library(cartogram)
library(sf)
library(tmap)

data("World")

# Keep only the African continent
afr <- World[World$continent == "Africa", ]

# Project the map
afr <- st_transform(afr, 3395)

# Plot the original map boundaries
tm_shape(afr) +
  tm_borders() +
  # Add the the cartogram
  tm_shape(cartogram_ncont(afr, "pop_est")) +
  tm_polygons("pop_est",
              fill.scale = tm_scale_intervals(style = "jenks")) +
  tm_layout(frame = FALSE,
            legend.position = c("left", "bottom"))
```

### Non-Overlapping Circles Cartogram

```{r dorling, fig.asp = 1.2}
library(cartogram)
library(sf)
library(tmap)

data("World")

# Keep only the African continent
afr <- World[World$continent == "Africa", ]

# Project the map
afr <- st_transform(afr, 3395)

# Plot the original map boundaries
tm_shape(afr) +
  tm_borders() +
  # Add the the cartogram
  tm_shape(cartogram_dorling(afr, "pop_est")) +
  tm_polygons("pop_est",
              fill.scale = tm_scale_intervals(style = "jenks")) +
  tm_layout(frame = FALSE,
            legend.position = c("left", "bottom"))
```

## Use multiple CPU cores

```{r parallel, fig.asp = 1.2}
library(cartogram)
library(sf)
library(tmap)
library(future)
library(future.apply)
library(parallelly)
library(progressr)

data("World")

# Keep only the African continent
afr <- World[World$continent == "Africa", ]

# Project the map
afr <- st_transform(afr, 3395)

# Create cartogram using 2 CPU cores on the local machine
# This can speed up computation for larger datasets.
# Set show_progress to TRUE for a progress indicator.
afr_cont <- cartogram_cont(afr, weight = "pop_est",
                            itermax = 5, 
                            n_cpu = 2,
                            show_progress = FALSE)

# Plot the cartogram
tm_shape(afr_cont) +
  tm_polygons("pop_est",
              fill.scale = tm_scale_intervals(style = "jenks")) +
  tm_layout(frame = FALSE,
            legend.position = c("left", "bottom"))
```

## Acknowledgements

The non-contiguous area cartogram and non-overlapping circles cartogram functionalities include major code contributions from [@rCarto](https://github.com/rCarto) and [@neocarto](https://github.com/neocarto).

[@nowosad](https://github.com/nowosad) contributed to the package by transitioning it to use the `sf` package and by enhancing the documentation, a task further supported by documentation improvements from [@oliveroy](https://github.com/oliveroy).

The functionality to utilize multiple CPU cores was contributed by [@e-kotov](https://github.com/e-kotov).

## References

This package implements algorithms based on the following seminal works:

* Dorling, D. (1996). Area Cartograms: Their Use and Creation. In Concepts and Techniques in Modern Geography (CATMOG), 59.
* Dougenik, J. A., Chrisman, N. R., & Niemeyer, D. R. (1985). An Algorithm To Construct Continuous Area Cartograms. In The Professional Geographer, 37(1), 75-81.
* Olson, J. M. (1976), Noncontiguous Area Cartograms. The Professional Geographer, 28: 371–380. [doi:10.1111/j.0033-0124.1976.00371.x](https://doi.org/10.1111/j.0033-0124.1976.00371.x)

Owner

  • Name: Sebastian Jeworutzki
  • Login: sjewo
  • Kind: user
  • Location: Bochum
  • Company: Ruhr-Universität Bochum

GitHub Events

Total
  • Issues event: 10
  • Watch event: 2
  • Issue comment event: 42
  • Push event: 39
  • Pull request review event: 10
  • Pull request review comment event: 11
  • Pull request event: 7
  • Fork event: 2
  • Create event: 2
Last Year
  • Issues event: 10
  • Watch event: 2
  • Issue comment event: 42
  • Push event: 39
  • Pull request review event: 10
  • Pull request review comment event: 11
  • Pull request event: 7
  • Fork event: 2
  • Create event: 2

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 186
  • Total Committers: 6
  • Avg Commits per committer: 31.0
  • Development Distribution Score (DDS): 0.328
Past Year
  • Commits: 71
  • Committers: 2
  • Avg Commits per committer: 35.5
  • Development Distribution Score (DDS): 0.465
Top Committers
Name Email Commits
Sebastian Jeworutzki s****i@r****e 125
Egor Kotov k****r@g****m 33
jn t****i@g****m 17
rCarto t****d@c****r 5
olivroy o****1@h****m 5
Timothée Giraud t****d@u****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 24
  • Total pull requests: 23
  • Average time to close issues: over 1 year
  • Average time to close pull requests: 4 months
  • Total issue authors: 17
  • Total pull request authors: 6
  • Average comments per issue: 2.42
  • Average comments per pull request: 2.61
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 7
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 1 month
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 0.2
  • Average comments per pull request: 3.86
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sjewo (5)
  • e-kotov (3)
  • Nowosad (2)
  • bctclc (1)
  • mike-duran-mitchell (1)
  • binkleym (1)
  • flashton2003 (1)
  • jeffeaton (1)
  • rsbivand (1)
  • bananaonthemoon (1)
  • stevepowell99 (1)
  • shadrackkibet (1)
  • neuwirthe (1)
  • popovs (1)
  • fgoerlich (1)
Pull Request Authors
  • Nowosad (7)
  • e-kotov (6)
  • sjewo (5)
  • olivroy (4)
  • rCarto (2)
  • spiry34 (2)
Top Labels
Issue Labels
enhancement (3)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 1,121 last-month
  • Total docker downloads: 303
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 11
    (may contain duplicates)
  • Total versions: 10
  • Total maintainers: 1
proxy.golang.org: github.com/sjewo/cartogram
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 7 months ago
cran.r-project.org: cartogram

Create Cartograms with R

  • Versions: 8
  • Dependent Packages: 3
  • Dependent Repositories: 11
  • Downloads: 1,121 Last month
  • Docker Downloads: 303
Rankings
Stargazers count: 2.9%
Forks count: 4.8%
Downloads: 7.8%
Dependent repos count: 8.8%
Average: 10.4%
Dependent packages count: 10.9%
Docker downloads count: 27.4%
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
  • methods * imports
  • packcircles * imports
  • sf * imports
  • maptools * suggests
  • rgdal * suggests
  • rgeos * suggests
  • sp * suggests