Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/thiyangt/ceylon
- Owner: thiyangt
- License: gpl-3.0
- Created: 2021-03-02T08:18:54.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-18T12:18:24.000Z (12 months ago)
- Last Synced: 2024-01-18T15:21:13.793Z (12 months ago)
- Language: R
- Homepage:
- Size: 43.8 MB
- Stars: 11
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
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%"
)
```![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/).