13 changed files with 664 additions and 16 deletions
@ -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 |
|||
|
@ -0,0 +1,2 @@ |
|||
YEAR: 2020 |
|||
COPYRIGHT HOLDER: Bob Rudis |
@ -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. |
@ -1,4 +1,4 @@ |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
import(httr) |
|||
importFrom(jsonlite,fromJSON) |
|||
export(imago) |
|||
import(sf) |
|||
|
@ -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" |
|||
|
@ -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"), ... |
|||
) |
|||
} |
@ -0,0 +1,129 @@ |
|||
|
|||
[](https://www.repostatus.org/#active) |
|||
[](https://keybase.io/hrbrmstr) |
|||
 |
|||
[](https://travis-ci.org/hrbrmstr/imago) |
|||
 |
|||
 |
|||
|
|||
# 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. |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 155 KiB |
Loading…
Reference in new issue