Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thiyangt/ceylon

Plot maps of Sri Lanka
https://github.com/thiyangt/ceylon

Last synced: 2 months ago
JSON representation

Plot maps of Sri Lanka

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# ceylon

![https://zenodo.org/badge/DOI/10.5281/zenodo.10432141.svg](https://zenodo.org/badge/DOI/10.5281/zenodo.10432141.svg)

The goal of ceylon is to provide data to plot maps of Sri Lanka.

## Installation

You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("thiyangt/ceylon")
```

## 1. Country level

```{r example}
library(ceylon)
library(tidyverse)
library(sp)
library(viridis)
data(sf_sl_0)
ggplot(sf_sl_0) + geom_sf()
```

## 2. Provinces of Sri Lanka

```{r example0}
data(province)
province
ggplot(province) + geom_sf(mapping = aes(), show.legend = TRUE)
```

## 3. Districts in Sri Lanka

```{r example2}
data(district)
ggplot(district) + geom_sf() + scale_fill_viridis()
```

## 4. Divisional secretariats in Sri Lanka

```{r example3}
data(sf_sl_3)
ggplot(sf_sl_3) + geom_sf()
```

## 5. Plotting river network in Sri Lanka

```{r}
data("rivers")
ggplot(data = sf_sl_0) +
geom_sf(fill="#edf8b1", color="#AAAAAA") +
geom_sf(data=rivers, colour="#253494") +
labs(title = "Sri Lanka Rivers and Streams")
```

## Making different types of Maps

### Choropleth Map

```{r}
ggplot(province) +
geom_sf(mapping = aes(fill = population), show.legend = TRUE) + scale_fill_viridis()
```

### Contiguous Cartogram

```{r, carto}
library(cartogram)
library(sf)
library(sp)
cont <- cartogram_cont(province,
weight = "population") |>
st_as_sf()
ggplot(cont) +
geom_sf(aes(fill = population), colour = "white") + scale_fill_viridis()
```

### Non-Contiguous Cartogram

```{r, ncont}
ncont <- cartogram_ncont(province,
weight = "population") |>
st_as_sf()
ggplot(ncont) +
geom_sf(data = province) +
geom_sf(aes(fill = population), colour = "white") + scale_fill_viridis()
```

### Dorling Cartogram

```{r, dorl}
dorl <- cartogram_dorling(province,
weight = "population") |>
st_as_sf()
ggplot(dorl) +
geom_sf(data = province) +
geom_sf(aes(fill = population), colour = "white") + scale_fill_viridis()
```

## Cite

Talagala, T. S. (2023). ceylon: Creating Maps of Sri Lanka Administrative Regions, Rivers and Streams. Zenodo. https://doi.org/10.5281/zenodo.10432141

### Working paper

Talagala, T. S. (2024). ceylon: An R package for plotting the maps of Sri Lanka. arXiv preprint arXiv:2401.02467.

### Acknowledgement

This package is inspired by the talk given by [Stephanie Kobakian](https://srk.netlify.app/) at [R-Ladies Colombo meetup](https://rladiescolombo.netlify.app/talk/3_map/).