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:
lineworks
: Return vector of available linework shapes and optionally print verbose description of shapfile data elements.linework_map
: Retrieve a linework map as a regular or fortified SpatialPolygonsDataFrame
The following data sets are included:
linework
: Project Linework spatial & fortified objectsdevtools::install_github("hrbrmstr/lineworkmaps")
options(width=120)
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)
library(lineworkmaps) library(testthat) date() test_dir("tests/")
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.