knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README_files/README-"
)

lineworkmaps is compilation of Project Linework maps in SpatialPolygonsDataFrame and ggplot2 fortified objects ready for mapping, et al.

I took a minimalist approach to the package in that I don't have every linework (the calligraphy one seemed less than useful) and the functions only work for Admin 0 & Admin 1 polygons.

Please file an issue if there is functionality you'd like to see that isn't included. The package is at a very early stage so almost no suggestion will be turned away!

To get an idea of what you can do with these lineworks in R, head on over to RPubs. It has been updated to use this package.

The Project Linework shapefiles also work well with Leaflet.

The following functions are implemented:

The following data sets are included:

News

Installation

devtools::install_github("hrbrmstr/lineworkmaps")
options(width=120)

Usage

library(lineworkmaps)
library(sp)
library(ggplot2)
library(ggthemes)

# current verison
packageVersion("lineworkmaps")

# plot admin1 polygons for Elmer Casual (the defaults)
plot(linework_map())

# plot the continental United States "Wargames" style
wargames <- linework_map("wargames", fortified=TRUE)

us <- wargames[wargames$iso_a2=="US" & 
               !wargames$code_hasc %in% c("US.HI", "US.AK"),]

ggplot(us) +
  geom_map(map=us, aes(x=long, y=lat, map_id=id)) +
  coord_map(project="albers", lat0=37.5, lat1=29.5) +
  theme_map()

# fancier example just focusing on the U.S.
elmer <- linework_map("elmer_casual", fortified=TRUE)

us <- elmer[elmer$COUNTRY=="US" & 
            elmer$Name != "Alaska",]

gg <- ggplot()
gg <- gg + geom_map(data=us, map=us,
                    aes(x=long, y=lat, map_id=id),
                    color="#939598", fill="#d1d2d4", size=0.5)
gg <- gg + coord_map(project="albers", lat0=37.5, lat1=29.5)
gg <- gg + labs(title="Elmer Casual")
gg <- gg + theme_map()
gg <- gg + theme(plot.title=element_text(size=16))
gg

# new maps: moriarty hand & weekend update

moriarty <- linework_map("moriarty_hand", fortified=TRUE)

us <- moriarty[substring(moriarty$ISO_3166_2, 1, 2) =="US" & 
               !(moriarty$ISO_3166_2 %in% c("US-AK", "US-HI")),]

gg <- ggplot()
gg <- gg + geom_map(data=us, map=us,
                    aes(x=long, y=lat, map_id=id),
                    color="#939598", fill="#d1d2d4", size=0.5)
gg <- gg + coord_map(project="albers", lat0=37.5, lat1=29.5)
gg <- gg + labs(title="Moriarty Hand Admin 1 CONUS")
gg <- gg + theme_map()
gg <- gg + theme(plot.title=element_text(size=16))
gg


moriarty <- linework_map("moriarty_hand", admin_level=0, fortified=FALSE)
moriarty <- subset(moriarty, region_un=="Africa")
moriarty <- fortify(moriarty)

gg <- ggplot()
gg <- gg + geom_map(data=moriarty, map=moriarty,
                    aes(x=long, y=lat, map_id=id),
                    color="#939598", fill="#d1d2d4", size=0.5)
gg <- gg + coord_quickmap()
gg <- gg + labs(title="Moriarty Hand Admin 0 - Africa")
gg <- gg + theme_map()
gg <- gg + theme(plot.title=element_text(size=16))
gg

weekend <- linework_map("weekend_update", admin_level=0, fortified=TRUE)
weekend <- subset(weekend, Country != "United States")

gg <- ggplot()
gg <- gg + geom_map(data=weekend, map=weekend,
                    aes(x=long, y=lat, map_id=id),
                    color="#939598", fill="#d1d2d4", size=0.5)
gg <- gg + coord_quickmap()
gg <- gg + labs(title="Weekend Update - Europe")
gg <- gg + theme_map()
gg <- gg + theme(plot.title=element_text(size=16))
gg

# info about the lineworks
lineworks(verbose=TRUE)

Test Results

library(lineworkmaps)
library(testthat)

date()

test_dir("tests/")

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.



hrbrmstr/lineworkmaps documentation built on May 17, 2019, 5:10 p.m.