Browse Source

initial commit

master
boB Rudis 4 years ago
parent
commit
625dfce01a
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 18
      DESCRIPTION
  3. 2
      LICENSE
  4. 21
      LICENSE.md
  5. 4
      NAMESPACE
  6. 10
      R/imago-package.R
  7. 15
      R/imago.R
  8. 48
      README.Rmd
  9. 129
      README.md
  10. 408
      inst/geojson/imago-final.geojson
  11. BIN
      man/figures/README-ex-01-1.png
  12. BIN
      man/figures/README-ex-02-1.png
  13. 22
      man/imago.Rd

1
.Rbuildignore

@ -19,3 +19,4 @@
^CRAN-RELEASE$
^appveyor\.yml$
^tools$
^LICENSE\.md$

18
DESCRIPTION

@ -1,24 +1,28 @@
Package: imago
Type: Package
Title: imago title goes here otherwise CRAN checks fail
Title: Hacky World Map GeoJSON Based on the Imago Projection
Version: 0.1.0
Date: 2020-03-20
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640"))
comment = c(ORCID = "0000-0001-5670-2640")),
person("Justin", "Kunimune", role = "aut",
comment = "Imago projection")
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A good description goes here otherwise CRAN checks fail.
Description: In 2017, Justin Kunimune reverse engineerd
(<https://kunimune.home.blog/2017/11/23/the-secrets-of-the-authagraph-revealed/>)
and open sourced the proprietary AuthaGraph (http://www.authagraph.com/top/?lang=en)
projection. Tools are provided to use this map in R for making
global choropleth charts.
URL: https://git.rud.is/hrbrmstr/imago
BugReports: https://git.rud.is/hrbrmstr/imago/issues
Encoding: UTF-8
License: AGPL
License: MIT + file LICENSE
Suggests:
covr, tinytest
Depends:
R (>= 3.2.0)
Imports:
httr,
jsonlite
Imports: sf
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2020 Bob Rudis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4
NAMESPACE

@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
import(httr)
importFrom(jsonlite,fromJSON)
export(imago)
import(sf)

10
R/imago-package.R

@ -1,9 +1,13 @@
#' ...
#' Hacky World Map GeoJSON Based on the Imago Projection
#'
#' In 2017, Justin Kunimune reverse engineerd
#' (<https://kunimune.home.blog/2017/11/23/the-secrets-of-the-authagraph-revealed/>)
#' and open sourced the proprietary AuthaGraph (http://www.authagraph.com/top/?lang=en)
#' projection. Tools are provided to use this map in R for making global chorpleth charts.
#'
#' @md
#' @name imago
#' @keywords internal
#' @author Bob Rudis (bob@@rud.is)
#' @import httr
#' @importFrom jsonlite fromJSON
#' @import sf
"_PACKAGE"

15
R/imago.R

@ -0,0 +1,15 @@
#' Read in an Imago world map
#'
#' The resultant simplefeatures object has a `iso3c` column
#' so you can bind values. A most-certainly non-iso3c value of
#' `lakes` is used to identify inland bodies of water.
#'
#' @param ... passed on to [sf::st_read()]
#' @export
#' @examples
#' plot(imago())
imago <- function(...) {
st_read(
system.file("geojson", "imago-final.geojson", package = "imago"), ...
)
}

48
README.Rmd

@ -29,6 +29,10 @@ hrbrpkghelpr::describe_ingredients()
hrbrpkghelpr::install_block()
```
## NOTE
This is really only suitable for choropleths. You're not going to be able to plot lon/lat on this since it was a hacky conversion from an SVG file to a woefully inaccurate projected GeoJSON, done mostly for a friend.
## Usage
```{r lib-ex}
@ -39,6 +43,50 @@ packageVersion("imago")
```
```{r ex-01}
plot(imago())
```
```{r ex-02, fig.width = 1300/96, fig.height = 700/96}
library(hrbrthemes)
library(countrycode)
library(tidyverse)
cols(
.default = col_double(),
date = col_date(format = "")
) -> covid_cols
read_csv(
file = "https://covid.ourworldindata.org/data/who/total_cases.csv",
col_types = covid_cols
) %>%
tail(1) %>%
gather(country, cases, -date) %>%
filter(!(country %in% c("World", "International", "Saint Barthlemy"))) %>%
mutate(iso3c = countrycode(country, "country.name", "iso3c")) %>%
select(-date, -country) -> covid_global
left_join(
imago(quiet = TRUE, stringsAsFactors = FALSE),
covid_global,
by = "iso3c"
) %>%
ggplot() +
geom_sf(
aes(fill = cases), color = "black", size = 0.25
) +
scale_fill_viridis_c(
name = "# Cases\n(log10)", na.value = "white",
direction = -1, trans = "log10", label = scales::comma
) +
coord_sf(datum = NA) +
labs(title = sprintf("Covid cases as of %s", Sys.Date())) +
theme_ipsum_es(grid="") +
theme(legend.key.width = unit(2.5, "lines")) +
theme(legend.position = "bottom")
```
## imago Metrics
```{r cloc, echo=FALSE}

129
README.md

@ -0,0 +1,129 @@
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/imago.svg?branch=master)](https://travis-ci.org/hrbrmstr/imago)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# imago
Hacky World Map GeoJSON Based on the Imago Projection
## Description
In 2017, Justin Kunimune reverse engineerd
(<https://kunimune.home.blog/2017/11/23/the-secrets-of-the-authagraph-revealed/>)
and open sourced the proprietary AuthaGraph
(<http://www.authagraph.com/top/?lang=en>) projection. Tools are
provided to use this map in R for making global choropleth charts.
## What’s Inside The Tin
The following functions are implemented:
## Installation
``` r
remotes::install_git("https://git.rud.is/hrbrmstr/imago.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/imago")
# or
remotes::install_gitlab("hrbrmstr/imago")
# or
remotes::install_bitbucket("hrbrmstr/imago")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## NOTE
This is really only suitable for choropleths. You’re not going to be
able to plot lon/lat on this since it was a hacky conversion from an SVG
file to a woefully inaccurate projected GeoJSON, done mostly for a
friend.
## Usage
``` r
library(imago)
# current version
packageVersion("imago")
## [1] '0.1.0'
```
``` r
plot(imago())
## Reading layer `imago-final' from data source `/Library/Frameworks/R.framework/Versions/3.6/Resources/library/imago/geojson/imago-final.geojson' using driver `GeoJSON'
## Simple feature collection with 401 features and 1 field
## geometry type: GEOMETRY
## dimension: XY
## bbox: xmin: -121.9723 ymin: 37.37338 xmax: -121.969 ymax: 37.37454
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
```
<img src="man/figures/README-ex-01-1.png" width="672" />
``` r
library(hrbrthemes)
library(countrycode)
library(tidyverse)
cols(
.default = col_double(),
date = col_date(format = "")
) -> covid_cols
read_csv(
file = "https://covid.ourworldindata.org/data/who/total_cases.csv",
col_types = covid_cols
) %>%
tail(1) %>%
gather(country, cases, -date) %>%
filter(!(country %in% c("World", "International", "Saint Barthlemy"))) %>%
mutate(iso3c = countrycode(country, "country.name", "iso3c")) %>%
select(-date, -country) -> covid_global
left_join(
imago(quiet = TRUE, stringsAsFactors = FALSE),
covid_global,
by = "iso3c"
) %>%
ggplot() +
geom_sf(
aes(fill = cases), color = "black", size = 0.25
) +
scale_fill_viridis_c(
name = "# Cases\n(log10)", na.value = "white",
direction = -1, trans = "log10", label = scales::comma
) +
coord_sf(datum = NA) +
labs(title = sprintf("Covid cases as of %s", Sys.Date())) +
theme_ipsum_es(grid="") +
theme(legend.key.width = unit(2.5, "lines")) +
theme(legend.position = "bottom")
```
<img src="man/figures/README-ex-02-1.png" width="1300" />
## imago Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| Rmd | 1 | 0.25 | 43 | 0.83 | 22 | 0.92 | 34 | 0.61 |
| R | 3 | 0.75 | 9 | 0.17 | 2 | 0.08 | 22 | 0.39 |
## Code of Conduct
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

408
inst/geojson/imago-final.geojson

File diff suppressed because one or more lines are too long

BIN
man/figures/README-ex-01-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
man/figures/README-ex-02-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

22
man/imago.Rd

@ -1,12 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/imago-package.R
% Please edit documentation in R/imago-package.R, R/imago.R
\docType{package}
\name{imago}
\alias{imago}
\alias{imago-package}
\title{...}
\title{Hacky World Map GeoJSON Based on the Imago Projection}
\usage{
imago(...)
}
\arguments{
\item{...}{passed on to \code{\link[sf:st_read]{sf::st_read()}}}
}
\description{
A good description goes here otherwise CRAN checks fail.
In 2017, Justin Kunimune reverse engineerd
(\url{https://kunimune.home.blog/2017/11/23/the-secrets-of-the-authagraph-revealed/})
and open sourced the proprietary AuthaGraph (http://www.authagraph.com/top/?lang=en)
projection. Tools are provided to use this map in R.
The resultant simplefeatures object has a \code{iso3c} column
so you can bind values. A most-certainly non-iso3c value of
\code{lakes} is used to identify inland bodies of water.
}
\examples{
plot(imago())
}
\seealso{
Useful links:

Loading…
Cancel
Save