Browse Source

data, README, CRAN checks

master
boB Rudis 8 years ago
parent
commit
7eef1cde22
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 2
      .Rbuildignore
  2. 12
      DESCRIPTION
  3. 2
      LICENSE
  4. 14
      R/albersusa-package.R
  5. 10
      R/albersusa.R
  6. 31
      R/counties.r
  7. 10
      R/proj.r
  8. 13
      README.Rmd
  9. 280
      README.html
  10. 181
      README.md
  11. BIN
      README_files/figure-html/unnamed-chunk-3-11.png
  12. BIN
      README_files/figure-html/unnamed-chunk-3-12.png
  13. BIN
      README_files/figure-html/unnamed-chunk-3-15.png
  14. BIN
      README_files/figure-html/unnamed-chunk-3-5.png
  15. 0
      README_files/figure-markdown_github/unnamed-chunk-3-1.png
  16. 0
      README_files/figure-markdown_github/unnamed-chunk-3-10.png
  17. BIN
      README_files/figure-markdown_github/unnamed-chunk-3-11.png
  18. BIN
      README_files/figure-markdown_github/unnamed-chunk-3-12.png
  19. 0
      README_files/figure-markdown_github/unnamed-chunk-3-13.png
  20. 0
      README_files/figure-markdown_github/unnamed-chunk-3-14.png
  21. BIN
      README_files/figure-markdown_github/unnamed-chunk-3-15.png
  22. 0
      README_files/figure-markdown_github/unnamed-chunk-3-16.png
  23. 0
      README_files/figure-markdown_github/unnamed-chunk-3-17.png
  24. 0
      README_files/figure-markdown_github/unnamed-chunk-3-18.png
  25. 0
      README_files/figure-markdown_github/unnamed-chunk-3-19.png
  26. 0
      README_files/figure-markdown_github/unnamed-chunk-3-2.png
  27. 0
      README_files/figure-markdown_github/unnamed-chunk-3-3.png
  28. 0
      README_files/figure-markdown_github/unnamed-chunk-3-4.png
  29. BIN
      README_files/figure-markdown_github/unnamed-chunk-3-5.png
  30. 0
      README_files/figure-markdown_github/unnamed-chunk-3-6.png
  31. 0
      README_files/figure-markdown_github/unnamed-chunk-3-7.png
  32. 0
      README_files/figure-markdown_github/unnamed-chunk-3-8.png
  33. 0
      README_files/figure-markdown_github/unnamed-chunk-3-9.png
  34. 3150
      inst/extdata/composite_us_counties.geojson
  35. BIN
      inst/extdata/composite_us_counties.geojson.gz
  36. 57
      inst/extdata/composite_us_states.geojson
  37. BIN
      inst/extdata/composite_us_states.geojson.gz
  38. BIN
      inst/extdata/counties.rda
  39. 17
      man/albersusa.Rd
  40. 29
      man/counties_composite.Rd
  41. 2
      man/us_aeqd_proj.Rd
  42. 2
      man/us_eqdc_proj.Rd
  43. 2
      man/us_laea_proj.Rd
  44. 2
      man/us_lcc_proj.Rd
  45. 2
      man/us_longlat_proj.Rd
  46. 12
      man/usa_composite.Rd
  47. 14
      tests/testthat/test-albersusa.R

2
.Rbuildignore

@ -5,4 +5,4 @@
^README\.*html$
^NOTES\.*md$
^NOTES\.*html$
^README_files/$
^README_files

12
DESCRIPTION

@ -1,14 +1,18 @@
Package: albersusa
Type: Package
Title: Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
Version: 0.1.0
Date: 2016-03-28
Version: 0.2.0
Date: 2016-03-29
Author: Bob Rudis (@hrbrmstr)
Maintainer: Bob Rudis <bob@rudis.net>
Description: Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
Description: Creating a composite projection for states and counties of the United States
that includes scaled and shifted polygons for Alaska and Hawaii is time consuming
and potentially error-prone. Functions and data sets are provided to make it easier to
produce maps with a composite projection. Furthermore, named projections for common
transormations are provided to further increase mapping productivity.
URL: http://github.com/hrbrmstr/albersusa
BugReports: https://github.com/hrbrmstr/albersusa/issues
License: AGPL + file LICENSE
License: AGPL
Suggests:
testthat,
ggalt

2
LICENSE

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

14
R/albersusa-package.R

@ -1,5 +1,19 @@
#' Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
#'
#' Creating a composite projection for states and counties of the United States
#' that includes scaled and shifted polygons for Alaska and Hawaii is time consuming
#' and potentially error-prone. Functions and data sets are provided to make it easier to
#' produce maps with a composite projection. Furthermore, named projections for common
#' transormations are provided to further increase mapping productivity.
#'
#' Reference GeoJSON files are provided in the following locations (i.e. you can use
#' them in any mapping program):
#'
#' \preformatted{
#' system.file("extdata/composite_us_states.geojson.gz", package="albersusa")
#' system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")
#' }
#'
#' @name albersusa
#' @docType package
#' @author Bob Rudis (@@hrbrmstr)

10
R/albersusa.R

@ -22,12 +22,20 @@
#' $ pop_2014 (int) 6731484, 2966369, 38802500, 5355866, 3596677, 6588...
#' }
#'
#' A reference GeoJSON file is provided in the following location (i.e. you can use
#' it in any mapping program):
#'
#' \preformatted{
#' system.file("extdata/composite_us_states.geojson.gz", package="albersusa")
#' }
#'
#' @param proj if anything but \code{longlat} is specified, the shapefile will
#' be pre-projected before being returned
#' @export
#' @examples
#' plot(usa_composite())
#' library(sp)
#'
#' plot(usa_composite())
#' plot(usa_composite("laea"))
usa_composite <- function(proj=c("longlat", "laea", "lcc", "eqdc", "aeqd")) {

31
R/counties.r

@ -8,27 +8,36 @@
#'
#' \preformatted{
#' Observations: 3,143
#' Variables: 8
#' $ fips (chr) "01001", "01009", "01017", "01021", "01033", "010...
#' $ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "...
#' $ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", ...
#' $ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colb...
#' $ lsad (chr) "County", "County", "County", "County", "County",...
#' $ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561....
#' $ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alab...
#' $ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "...
#' Variables: 9
#' $ fips (chr) "01001", "01009", "01017", "01021", "01033", "01045", "01051",...
#' $ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "0...
#' $ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", "065", "079",...
#' $ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colbert", "Dale",...
#' $ lsad (chr) "County", "County", "County", "County", "County", "County", "C...
#' $ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485,...
#' $ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabam...
#' $ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "A...
#' $ population (dbl) 54590, 57466, 34228, 43611, 54451, 50129, 79330, 15750, 34148,...
#' }
#'
#' A reference GeoJSON file isprovided in the following location (i.e. you can use
#' it in any mapping program):
#'
#' \preformatted{
#' system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")
#' }
#'
#' @param proj if anything but \code{longlat} is specified, the shapefile will
#' be pre-projected before being returned
#' @export
#' @examples
#' plot(counties_composite())
#' library(sp)
#'
#' plot(counties_composite())
#' plot(counties_composite("laea"))
counties_composite <- function(proj=c("longlat", "laea", "lcc", "eqdc", "aeqd")) {
# us <- readOGR(system.file("extdata/counties_composite.geojson", package="albersusa"),
# us <- readOGR(system.file("extdata/composite_us_counties.geojson", package="albersusa"),
# "OGRGeoJSON",
# stringsAsFactors=FALSE,
# verbose=FALSE)

10
R/proj.r

@ -9,7 +9,7 @@
#' @export
#' @examples
#' us <- usa_composite()
#' us <- sp::spTransform(us, CRS(us_laea_proj))
#' us <- sp::spTransform(us, sp::CRS(us_laea_proj))
#' us <- usa_composite(proj="laea")
#' counties <- counties_composite("laea")
us_laea_proj <- "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"
@ -25,7 +25,7 @@ us_laea_proj <- "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=63
#' @export
#' @examples
#' us <- usa_composite() # it's the default
#' us <- sp::spTransform(us, CRS(us_longlat_proj))
#' us <- sp::spTransform(us, sp::CRS(us_longlat_proj))
#' counties <- counties_composite()
us_longlat_proj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
@ -41,7 +41,7 @@ us_longlat_proj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,
#' @export
#' @examples
#' us <- usa_composite()
#' us <- sp::spTransform(us, CRS(us_lcc_proj))
#' us <- sp::spTransform(us, sp::CRS(us_lcc_proj))
#' us <- usa_composite(proj="lcc")
#' counties <- counties_composite("lcc")
us_lcc_proj <- "+proj=lcc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875"
@ -60,7 +60,7 @@ us_lcc_proj <- "+proj=lcc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lo
#' @export
#' @examples
#' us <- usa_composite()
#' us <- sp::spTransform(us, CRS(us_eqdc_proj))
#' us <- sp::spTransform(us, sp::CRS(us_eqdc_proj))
#' us <- usa_composite(proj="eqdc")
#' counties <- counties_composite("eqdc")
#'
@ -80,7 +80,7 @@ us_eqdc_proj <- "+proj=eqdc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +
#' @export
#' @examples
#' us <- usa_composite()
#' us <- sp::spTransform(us, CRS(us_aeqd_proj))
#' us <- sp::spTransform(us, sp::CRS(us_aeqd_proj))
#' us <- usa_composite(proj="aeqd")
#' counties <- counties_composite("aeqd")
us_aeqd_proj <- "+proj=aeqd +lat_0=40.08355112574181 +lon_0=-95.44921875"

13
README.Rmd

@ -1,9 +1,5 @@
---
output:
html_document:
keep_md: true
md_document:
variant: markdown_github
output: rmarkdown::github_document
---
`albersusa` : Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
@ -20,8 +16,11 @@ The following functions are implemented:
The following data sets are included:
- `system.file("extdata/composite_us_states.geojson", package="albersusa")` - composite GeoJSON
- `system.file("extdata/composite_us_counties.geojson", package="albersusa")` - composite GeoJSON
- `system.file("extdata/composite_us_states.geojson.gz", package="albersusa")`
- `system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")`
Also, the `@data` slot of each `SpatialPolygonsDataFrame` has some handy data you can
use (like FIPS codes and state/county population information).
### Installation

280
README.html

File diff suppressed because one or more lines are too long

181
README.md

@ -3,32 +3,30 @@
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
- `counties_composite`: Retreive a U.S. county composite map, optionally with a projection
- `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
- `counties_composite`: Retreive a U.S. county composite map, optionally with a projection
The following data sets are included:
- `system.file("extdata/composite_us_states.geojson", package="albersusa")` - composite GeoJSON
- `system.file("extdata/composite_us_counties.geojson", package="albersusa")` - composite GeoJSON
- `system.file("extdata/composite_us_states.geojson.gz", package="albersusa")`
- `system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")`
### Installation
Also, the `@data` slot of each `SpatialPolygonsDataFrame` has some handy data you can use (like FIPS codes and state/county population information).
### Installation
```r
``` r
devtools::install_github("hrbrmstr/albersusa")
```
### Usage
```r
``` r
library(albersusa)
library(sp)
library(rgeos)
@ -43,46 +41,42 @@ library(scales)
packageVersion("albersusa")
```
```
## [1] '0.1.0'
```
## [1] '0.2.0'
```r
``` r
us <- usa_composite()
dplyr::glimpse(us@data)
```
```
## Observations: 51
## Variables: 11
## $ geo_id (chr) "0400000US04", "0400000US05", "0400000US06", "0400000US08", "0400000US09", "0400000US11...
## $ fips_state (chr) "04", "05", "06", "08", "09", "11", "13", "17", "18", "22", "27", "28", "30", "35", "38...
## $ name (chr) "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "District of Columbia",...
## $ iso_3166_2 (chr) "AZ", "AR", "CA", "CO", "CT", "DC", "GA", "IL", "IN", "LA", "MN", "MS", "MT", "NM", "ND...
## $ census (dbl) 6392017, 2915918, 37253956, 5029196, 3574097, 601723, 9687653, 12830632, 6483802, 45333...
## $ pop_estimataes_base (dbl) 6392310, 2915958, 37254503, 5029324, 3574096, 601767, 9688681, 12831587, 6484192, 45334...
## $ pop_2010 (dbl) 6411999, 2922297, 37336011, 5048575, 3579345, 605210, 9714464, 12840097, 6490308, 45455...
## $ pop_2011 (dbl) 6472867, 2938430, 37701901, 5119661, 3590537, 620427, 9813201, 12858725, 6516560, 45759...
## $ pop_2012 (dbl) 6556236, 2949300, 38062780, 5191709, 3594362, 635040, 9919000, 12873763, 6537632, 46047...
## $ pop_2013 (dbl) 6634997, 2958765, 38431393, 5272086, 3599341, 649111, 9994759, 12890552, 6570713, 46292...
## $ pop_2014 (dbl) 6731484, 2966369, 38802500, 5355866, 3596677, 658893, 10097343, 12880580, 6596855, 4649...
```
```r
## Observations: 51
## Variables: 11
## $ geo_id (chr) "0400000US04", "0400000US05", "0400000US06", "0400000US08", "0400000US09", "0400000US11...
## $ fips_state (chr) "04", "05", "06", "08", "09", "11", "13", "17", "18", "22", "27", "28", "30", "35", "38...
## $ name (chr) "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "District of Columbia",...
## $ iso_3166_2 (chr) "AZ", "AR", "CA", "CO", "CT", "DC", "GA", "IL", "IN", "LA", "MN", "MS", "MT", "NM", "ND...
## $ census (dbl) 6392017, 2915918, 37253956, 5029196, 3574097, 601723, 9687653, 12830632, 6483802, 45333...
## $ pop_estimataes_base (dbl) 6392310, 2915958, 37254503, 5029324, 3574096, 601767, 9688681, 12831587, 6484192, 45334...
## $ pop_2010 (dbl) 6411999, 2922297, 37336011, 5048575, 3579345, 605210, 9714464, 12840097, 6490308, 45455...
## $ pop_2011 (dbl) 6472867, 2938430, 37701901, 5119661, 3590537, 620427, 9813201, 12858725, 6516560, 45759...
## $ pop_2012 (dbl) 6556236, 2949300, 38062780, 5191709, 3594362, 635040, 9919000, 12873763, 6537632, 46047...
## $ pop_2013 (dbl) 6634997, 2958765, 38431393, 5272086, 3599341, 649111, 9994759, 12890552, 6570713, 46292...
## $ pop_2014 (dbl) 6731484, 2966369, 38802500, 5355866, 3596677, 658893, 10097343, 12880580, 6596855, 4649...
``` r
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-1.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-1.png" width="672" />
```r
``` r
us <- usa_composite("laea")
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-2.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-2.png" width="672" />
```r
``` r
us <- usa_composite()
us_map <- fortify(us, region="name")
@ -95,45 +89,45 @@ gg <- gg + theme_map()
gg + coord_map()
```
<img src="README_files/figure-html/unnamed-chunk-3-3.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-3.png" width="672" />
```r
``` r
gg + coord_map("polyconic")
```
<img src="README_files/figure-html/unnamed-chunk-3-4.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-4.png" width="672" />
```r
``` r
gg + coord_proj()
```
<img src="README_files/figure-html/unnamed-chunk-3-5.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-5.png" width="672" />
```r
``` r
gg + coord_proj(us_laea_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-6.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-6.png" width="672" />
```r
``` r
gg + coord_proj(us_aeqd_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-7.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-7.png" width="672" />
```r
``` r
gg + coord_proj(us_eqdc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-8.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-8.png" width="672" />
```r
``` r
gg + coord_proj(us_lcc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-9.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-9.png" width="672" />
```r
``` r
gg +
geom_map(data=us@data, map=us_map,
aes(fill=pop_2014, map_id=name),
@ -143,41 +137,40 @@ gg +
theme(legend.position="right")
```
<img src="README_files/figure-html/unnamed-chunk-3-10.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-10.png" width="672" />
```r
``` r
us <- counties_composite()
dplyr::glimpse(us@data)
```
```
## Observations: 3,143
## Variables: 8
## $ fips (chr) "01001", "01009", "01017", "01021", "01033", "01045", "01051", "01065", "01079", "01083", "0109...
## $ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "05", "05", "06",...
## $ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", "065", "079", "083", "099", "107", "121", "141...
## $ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colbert", "Dale", "Elmore", "Hale", "Lawrence", "L...
## $ lsad (chr) "County", "County", "County", "County", "County", "County", "County", "County", "County", "Coun...
## $ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485, 643.943, 690.678, 559.936, 1025....
## $ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabam...
## $ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AR", "AR", "CA",...
```
## Observations: 3,143
## Variables: 9
## $ fips (chr) "01001", "01009", "01017", "01021", "01033", "01045", "01051", "01065", "01079", "01083", "0109...
## $ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "05", "05", "06",...
## $ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", "065", "079", "083", "099", "107", "121", "141...
## $ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colbert", "Dale", "Elmore", "Hale", "Lawrence", "L...
## $ lsad (chr) "County", "County", "County", "County", "County", "County", "County", "County", "County", "Coun...
## $ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485, 643.943, 690.678, 559.936, 1025....
## $ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabam...
## $ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AR", "AR", "CA",...
## $ population (dbl) 54590, 57466, 34228, 43611, 54451, 50129, 79330, 15750, 34148, 83313, 22993, 19646, 82194, 1722...
```r
``` r
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-11.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-11.png" width="672" />
```r
``` r
us <- counties_composite("laea")
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-12.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-12.png" width="672" />
```r
``` r
us <- counties_composite()
us_map <- fortify(us, region="fips")
@ -190,64 +183,58 @@ gg <- gg + theme_map()
gg + coord_map()
```
<img src="README_files/figure-html/unnamed-chunk-3-13.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-13.png" width="672" />
```r
``` r
gg + coord_map("polyconic")
```
<img src="README_files/figure-html/unnamed-chunk-3-14.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-14.png" width="672" />
```r
``` r
gg + coord_proj()
```
<img src="README_files/figure-html/unnamed-chunk-3-15.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-15.png" width="672" />
```r
``` r
gg + coord_proj(us_laea_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-16.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-16.png" width="672" />
```r
``` r
gg + coord_proj(us_aeqd_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-17.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-17.png" width="672" />
```r
``` r
gg + coord_proj(us_eqdc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-18.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-18.png" width="672" />
```r
``` r
gg + coord_proj(us_lcc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-19.png" title="" alt="" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-3-19.png" width="672" />
### Test Results
```r
``` r
library(albersusa)
library(testthat)
date()
```
```
## [1] "Mon Mar 28 23:32:07 2016"
```
## [1] "Tue Mar 29 13:22:01 2016"
```r
``` r
test_dir("tests/")
```
```
## testthat results ========================================================================================================
## OK: 0 SKIPPED: 0 FAILED: 0
```
## testthat results ========================================================================================================
## OK: 6 SKIPPED: 0 FAILED: 0

BIN
README_files/figure-html/unnamed-chunk-3-11.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

BIN
README_files/figure-html/unnamed-chunk-3-12.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 KiB

BIN
README_files/figure-html/unnamed-chunk-3-15.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 KiB

BIN
README_files/figure-html/unnamed-chunk-3-5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

0
README_files/figure-html/unnamed-chunk-3-1.png → README_files/figure-markdown_github/unnamed-chunk-3-1.png

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

0
README_files/figure-html/unnamed-chunk-3-10.png → README_files/figure-markdown_github/unnamed-chunk-3-10.png

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-3-11.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-3-12.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

0
README_files/figure-html/unnamed-chunk-3-13.png → README_files/figure-markdown_github/unnamed-chunk-3-13.png

Before

Width:  |  Height:  |  Size: 370 KiB

After

Width:  |  Height:  |  Size: 370 KiB

0
README_files/figure-html/unnamed-chunk-3-14.png → README_files/figure-markdown_github/unnamed-chunk-3-14.png

Before

Width:  |  Height:  |  Size: 348 KiB

After

Width:  |  Height:  |  Size: 348 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-3-15.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

0
README_files/figure-html/unnamed-chunk-3-16.png → README_files/figure-markdown_github/unnamed-chunk-3-16.png

Before

Width:  |  Height:  |  Size: 341 KiB

After

Width:  |  Height:  |  Size: 341 KiB

0
README_files/figure-html/unnamed-chunk-3-17.png → README_files/figure-markdown_github/unnamed-chunk-3-17.png

Before

Width:  |  Height:  |  Size: 340 KiB

After

Width:  |  Height:  |  Size: 340 KiB

0
README_files/figure-html/unnamed-chunk-3-18.png → README_files/figure-markdown_github/unnamed-chunk-3-18.png

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 332 KiB

0
README_files/figure-html/unnamed-chunk-3-19.png → README_files/figure-markdown_github/unnamed-chunk-3-19.png

Before

Width:  |  Height:  |  Size: 328 KiB

After

Width:  |  Height:  |  Size: 328 KiB

0
README_files/figure-html/unnamed-chunk-3-2.png → README_files/figure-markdown_github/unnamed-chunk-3-2.png

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

0
README_files/figure-html/unnamed-chunk-3-3.png → README_files/figure-markdown_github/unnamed-chunk-3-3.png

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

0
README_files/figure-html/unnamed-chunk-3-4.png → README_files/figure-markdown_github/unnamed-chunk-3-4.png

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-3-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

0
README_files/figure-html/unnamed-chunk-3-6.png → README_files/figure-markdown_github/unnamed-chunk-3-6.png

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

0
README_files/figure-html/unnamed-chunk-3-7.png → README_files/figure-markdown_github/unnamed-chunk-3-7.png

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 137 KiB

0
README_files/figure-html/unnamed-chunk-3-8.png → README_files/figure-markdown_github/unnamed-chunk-3-8.png

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB

0
README_files/figure-html/unnamed-chunk-3-9.png → README_files/figure-markdown_github/unnamed-chunk-3-9.png

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

3150
inst/extdata/composite_us_counties.geojson

File diff suppressed because one or more lines are too long

BIN
inst/extdata/composite_us_counties.geojson.gz

Binary file not shown.

57
inst/extdata/composite_us_states.geojson

File diff suppressed because one or more lines are too long

BIN
inst/extdata/composite_us_states.geojson.gz

Binary file not shown.

BIN
inst/extdata/counties.rda

Binary file not shown.

17
man/albersusa.Rd

@ -1,12 +1,25 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/albersusa-package.R
% Please edit documentation in R/albersusa-package.r
\docType{package}
\name{albersusa}
\alias{albersusa}
\alias{albersusa-package}
\title{Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection}
\description{
Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection
Creating a composite projection for states and counties of the United States
that includes scaled and shifted polygons for Alaska and Hawaii is time consuming
and potentially error-prone. Functions and data sets are provided to make it easier to
produce maps with a composite projection. Furthermore, named projections for common
transormations are provided to further increase mapping productivity.
}
\details{
Reference GeoJSON files are provided in the following locations (i.e. you can use
them in any mapping program):
\preformatted{
system.file("extdata/composite_us_states.geojson.gz", package="albersusa")
system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")
}
}
\author{
Bob Rudis (@hrbrmstr)

29
man/counties_composite.Rd

@ -20,20 +20,29 @@ This is what's in the SPDF \code{@data} slot:
\preformatted{
Observations: 3,143
Variables: 8
$ fips (chr) "01001", "01009", "01017", "01021", "01033", "010...
$ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "...
$ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", ...
$ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colb...
$ lsad (chr) "County", "County", "County", "County", "County",...
$ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561....
$ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alab...
$ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "...
Variables: 9
$ fips (chr) "01001", "01009", "01017", "01021", "01033", "01045", "01051",...
$ state_fips (chr) "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "0...
$ county_fips (chr) "001", "009", "017", "021", "033", "045", "051", "065", "079",...
$ name (chr) "Autauga", "Blount", "Chambers", "Chilton", "Colbert", "Dale",...
$ lsad (chr) "County", "County", "County", "County", "County", "County", "C...
$ census_area (dbl) 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485,...
$ state (chr) "Alabama", "Alabama", "Alabama", "Alabama", "Alabama", "Alabam...
$ iso_3166_2 (chr) "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "A...
$ population (dbl) 54590, 57466, 34228, 43611, 54451, 50129, 79330, 15750, 34148,...
}
A reference GeoJSON file isprovided in the following location (i.e. you can use
it in any mapping program):
\preformatted{
system.file("extdata/composite_us_counties.geojson.gz", package="albersusa")
}
}
\examples{
plot(counties_composite())
library(sp)
plot(counties_composite())
plot(counties_composite("laea"))
}

2
man/us_aeqd_proj.Rd

@ -19,7 +19,7 @@ parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_aeqd_proj)}.
}
\examples{
us <- usa_composite()
us <- sp::spTransform(us, CRS(us_aeqd_proj))
us <- sp::spTransform(us, sp::CRS(us_aeqd_proj))
us <- usa_composite(proj="aeqd")
counties <- counties_composite("aeqd")
}

2
man/us_eqdc_proj.Rd

@ -19,7 +19,7 @@ parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_eqdc_proj)}.
}
\examples{
us <- usa_composite()
us <- sp::spTransform(us, CRS(us_eqdc_proj))
us <- sp::spTransform(us, sp::CRS(us_eqdc_proj))
us <- usa_composite(proj="eqdc")
counties <- counties_composite("eqdc")

2
man/us_laea_proj.Rd

@ -17,7 +17,7 @@ parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_laea_proj)}.
}
\examples{
us <- usa_composite()
us <- sp::spTransform(us, CRS(us_laea_proj))
us <- sp::spTransform(us, sp::CRS(us_laea_proj))
us <- usa_composite(proj="laea")
counties <- counties_composite("laea")
}

2
man/us_lcc_proj.Rd

@ -17,7 +17,7 @@ parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_lcc_proj)}.
}
\examples{
us <- usa_composite()
us <- sp::spTransform(us, CRS(us_lcc_proj))
us <- sp::spTransform(us, sp::CRS(us_lcc_proj))
us <- usa_composite(proj="lcc")
counties <- counties_composite("lcc")
}

2
man/us_longlat_proj.Rd

@ -17,7 +17,7 @@ parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_longlat_proj)}
}
\examples{
us <- usa_composite() # it's the default
us <- sp::spTransform(us, CRS(us_longlat_proj))
us <- sp::spTransform(us, sp::CRS(us_longlat_proj))
counties <- counties_composite()
}
\keyword{datasets}

12
man/usa_composite.Rd

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/albersusa.R
% Please edit documentation in R/albersusa.r
\name{usa_composite}
\alias{usa_composite}
\title{Retreive a U.S. state composite map, optionally with a projection}
@ -33,10 +33,18 @@ $ pop_2012 (int) 6556236, 2949300, 38062780, 5191709, 3594362, 6350..
$ pop_2013 (int) 6634997, 2958765, 38431393, 5272086, 3599341, 6491...
$ pop_2014 (int) 6731484, 2966369, 38802500, 5355866, 3596677, 6588...
}
A reference GeoJSON file is provided in the following location (i.e. you can use
it in any mapping program):
\preformatted{
system.file("extdata/composite_us_states.geojson.gz", package="albersusa")
}
}
\examples{
plot(usa_composite())
library(sp)
plot(usa_composite())
plot(usa_composite("laea"))
}

14
tests/testthat/test-albersusa.R

@ -1,6 +1,16 @@
context("basic functionality")
context("Shapefile integrity")
test_that("we can do something", {
#expect_that(some_function(), is_a("data.frame"))
us <- usa_composite()
cty <- counties_composite()
expect_that(us, is_a("SpatialPolygonsDataFrame"))
expect_that(cty, is_a("SpatialPolygonsDataFrame"))
expect_that(dim(us), equals(c(51, 11)))
expect_that(dim(cty), equals(c(3143, 9)))
expect_that(length(us@polygons), equals(51))
expect_that(length(cty@polygons), equals(3143))
})

Loading…
Cancel
Save