Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/datagistips/geosparklines

An R Package to put SparkLines on a Map
https://github.com/datagistips/geosparklines

Last synced: 3 months ago
JSON representation

An R Package to put SparkLines on a Map

Awesome Lists containing this project

README

        

# geosparklines

`geosparklines` is an R package that you can use to create SparkLines as SimpleFeatureCollection (`sfc`) objects which can be further put on a map

## Quick Start

### Installation
```r
devtools::install_github("datagistips/geosparklines", build_vignettes = TRUE)
```

### Usage

Crteate geosparklines from a data frame
```r
library(geosparklines)
library(readr)
library(sf)

f <- read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv") # it's John Hopkins Institute Data

geosparks <- geospark(coords = f[, c("Long", "Lat")], my_stats = f[, 5:ncol(f)], width = 20, height = 20, mode = "log") # log transformed sparklines as an sfc (Simple Feature Collection)

st_geometry(f) <- geosparks
```

Or individual geosparklines, for which you can control the width, height, direction based on data
```r
sp_line <- singleGeospark(my_coords, v, width=20, height=20, direction="ne", mode="log")
```

There is also a method for generating sparklines inspired by FT Dataviz designer John Burn-Murdoch.
```r
sp_line <- geosparkBM(my_coords, my_values, width=3, height=4, n = 21, direction = "ne"))
```

Here are for example four geosparklines with varying widths, heights, and directions illustrating the evolution of covid-19 cases in France

![](vignettes/Rplot.png)

### Vignettes
- [Meet geosparklines with a reproducible example](vignettes/how-to-use-geosparklines.html)
- [See how to reproject your data to an Equal Area projection like Plate Carrée](vignettes/how-to-reproject-to-a-custom-plate-carree.html)
- [Put John Burn Murdoch's smoothed Sparklines on a map](vignettes/how-to-use-burn-murdoch-method.html)

## Rendering
You can render data in R, for instance with `ggplot` or `leaflet`

Also, you can export data :

```r
st_write(f, "data/my_geosparlines.gpkg) ## f is the sf object generated above
```

Then render it in [QGIS](https://www.qgis.org/)

Here is a map of covid cases in France, rendered in QGIS :

## License
License : GPL-3
Author : Mathieu Rajerison