|
|
|
---
|
|
|
|
output:
|
|
|
|
html_document:
|
|
|
|
keep_md: true
|
|
|
|
md_document:
|
|
|
|
variant: markdown_github
|
|
|
|
---
|
|
|
|
|
|
|
|
`albersusa` : Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
|
|
|
|
|
|
|
|
The following functions are implemented:
|
|
|
|
|
|
|
|
- `usa_composite`: Retreive a U.S. composite map, optionally with a projection
|
|
|
|
- `us_aeqd_proj`: Oblique azimuthal equidistant convenience projection
|
|
|
|
- `us_eqdc_proj`: Equidistant conic convenience projection
|
|
|
|
- `us_laea_proj`: Albers equal-area conic convenience projection
|
|
|
|
- `us_lcc_proj`: Lambert conformal conic convenience projection
|
|
|
|
- `us_longlat_proj`: Generic long/lat convenience projection
|
|
|
|
|
|
|
|
The following data sets are included:
|
|
|
|
|
|
|
|
- `system.file("extdata/composite_us_states.geojson", package="albersusa")` - composite GeoJSON
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
```{r eval=FALSE}
|
|
|
|
devtools::install_github("hrbrmstr/albersusa")
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
|
|
|
|
options(width=120)
|
|
|
|
```
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
```{r message=FALSE, fig.retina=2}
|
|
|
|
library(albersusa)
|
|
|
|
library(sp)
|
|
|
|
library(rgeos)
|
|
|
|
library(maptools)
|
|
|
|
library(ggplot2)
|
|
|
|
library(ggalt)
|
|
|
|
library(ggthemes)
|
|
|
|
library(viridis)
|
|
|
|
library(scales)
|
|
|
|
|
|
|
|
# current verison
|
|
|
|
packageVersion("albersusa")
|
|
|
|
|
|
|
|
us <- usa_composite()
|
|
|
|
|
|
|
|
dplyr::glimpse(us@data)
|
|
|
|
|
|
|
|
plot(us)
|
|
|
|
|
|
|
|
us <- usa_composite("laea")
|
|
|
|
plot(us)
|
|
|
|
|
|
|
|
us <- usa_composite()
|
|
|
|
us_map <- fortify(us, region="name")
|
|
|
|
|
|
|
|
gg <- ggplot()
|
|
|
|
gg <- gg + geom_map(data=us_map, map=us_map,
|
|
|
|
aes(x=long, y=lat, map_id=id),
|
|
|
|
color="#2b2b2b", size=0.1, fill=NA)
|
|
|
|
gg <- gg + theme_map()
|
|
|
|
|
|
|
|
gg + coord_map()
|
|
|
|
|
|
|
|
gg + coord_map("polyconic")
|
|
|
|
|
|
|
|
gg + coord_proj()
|
|
|
|
|
|
|
|
gg + coord_proj(us_laea_proj)
|
|
|
|
|
|
|
|
gg + coord_proj(us_aeqd_proj)
|
|
|
|
|
|
|
|
gg + coord_proj(us_eqdc_proj)
|
|
|
|
|
|
|
|
gg + coord_proj(us_lcc_proj)
|
|
|
|
|
|
|
|
gg +
|
|
|
|
geom_map(data=us@data, map=us_map,
|
|
|
|
aes(fill=pop_2014, map_id=name),
|
|
|
|
color="white", size=0.1) +
|
|
|
|
coord_proj(us_laea_proj) +
|
|
|
|
scale_fill_viridis(name="2014 Populaton Estimates", labels=comma) +
|
|
|
|
theme(legend.position="right")
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
### Test Results
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
library(albersusa)
|
|
|
|
library(testthat)
|
|
|
|
|
|
|
|
date()
|
|
|
|
|
|
|
|
test_dir("tests/")
|
|
|
|
```
|
|
|
|
|