boB Rudis
8 years ago
22 changed files with 485 additions and 4 deletions
@ -0,0 +1,7 @@ |
|||
^.*\.Rproj$ |
|||
^\.Rproj\.user$ |
|||
^\.travis\.yml$ |
|||
^README\.*md$ |
|||
^README\.*html$ |
|||
^NOTES\.*md$ |
|||
^NOTES\.*html$ |
@ -0,0 +1,25 @@ |
|||
language: r |
|||
warnings_are_errors: true |
|||
sudo: required |
|||
|
|||
env: |
|||
global: |
|||
- CRAN: http://cran.rstudio.com |
|||
|
|||
notifications: |
|||
email: |
|||
on_success: change |
|||
on_failure: change |
|||
|
|||
script: ./travis-tool.sh run_tests |
|||
|
|||
on_failure: |
|||
- ./travis-tool.sh dump_logs |
|||
|
|||
branches: |
|||
except: |
|||
- /-expt$/ |
|||
notifications: |
|||
email: |
|||
on_success: change |
|||
on_failure: change |
@ -0,0 +1,22 @@ |
|||
Package: albersusa |
|||
Type: Package |
|||
Title: Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection |
|||
Version: 0.1.0 |
|||
Date: 2016-03-28 |
|||
Author: Bob Rudis (@hrbrmstr) |
|||
Maintainer: Bob Rudis <bob@rudis.net> |
|||
Description: Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection |
|||
URL: http://github.com/hrbrmstr/albersusa |
|||
BugReports: https://github.com/hrbrmstr/albersusa/issues |
|||
License: AGPL + file LICENSE |
|||
Suggests: |
|||
testthat, |
|||
ggalt |
|||
Depends: |
|||
R (>= 3.0.0) |
|||
Imports: |
|||
sp, |
|||
rgeos, |
|||
rgdal, |
|||
maptools |
|||
RoxygenNote: 5.0.1 |
@ -0,0 +1,2 @@ |
|||
YEAR: 2016 |
|||
COPYRIGHT HOLDER: Bob Rudis |
@ -0,0 +1,12 @@ |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
export(us_aeqd_proj) |
|||
export(us_eqdc_proj) |
|||
export(us_laea_proj) |
|||
export(us_lcc_proj) |
|||
export(us_longlat_proj) |
|||
export(usa_composite) |
|||
import(maptools) |
|||
import(rgdal) |
|||
import(rgeos) |
|||
import(sp) |
@ -0,0 +1,2 @@ |
|||
0.1.0 |
|||
* Initial release |
@ -0,0 +1,7 @@ |
|||
#' Tools, Shapefiles & Data to Work with an 'AlbersUSA' Composite Projection |
|||
#' |
|||
#' @name albersusa |
|||
#' @docType package |
|||
#' @author Bob Rudis (@@hrbrmstr) |
|||
#' @import sp rgeos rgdal maptools |
|||
NULL |
@ -0,0 +1,39 @@ |
|||
#' Retreive a U.S. composite map, optionally with a projection |
|||
#' |
|||
#' The \code{proj} parameter is intende to simplify usage for those using base |
|||
#' plotting. If anything but \code{longlat} is specified the composite map |
|||
#' will be pre-projected to those |
|||
#' |
|||
#' @param proj if anything but \code{longlat} is specified, the shapefile will |
|||
#' be pre-projected before being returned |
|||
#' @export |
|||
#' @examples |
|||
#' plot(usa_composite()) |
|||
#' |
|||
#' plot(usa_composite("laea")) |
|||
usa_composite <- function(proj=c("longlat", "laea", "lcc", "eqdc", "aeqd")) { |
|||
|
|||
# us <- readOGR(system.file("extdata/composite_us_states.geojson", package="albersusa"), |
|||
# "OGRGeoJSON", |
|||
# stringsAsFactors=FALSE, |
|||
# verbose=FALSE) |
|||
|
|||
us <- readRDS(system.file("extdata/states.rda", package="albersusa")) |
|||
|
|||
proj <- match.arg(proj, c("longlat", "laea", "lcc", "eqdc", "aeqd")) |
|||
|
|||
if (proj != "longlat") { |
|||
|
|||
proj <- switch(proj, |
|||
laea=us_laea_proj, |
|||
lcc=us_lcc_proj, |
|||
eqdc=us_eqdc_proj, |
|||
aeqd=us_aeqd_proj) |
|||
|
|||
us <- sp::spTransform(us, sp::CRS(proj)) |
|||
|
|||
} |
|||
|
|||
us |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
#' Albers equal-area conic convenience projection |
|||
#' |
|||
#' The following PROJ.4 string is used: \code{+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs} |
|||
#' |
|||
#' In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
#' parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_laea_proj)}. |
|||
#' |
|||
#' @family convenience projections |
|||
#' @export |
|||
#' @examples |
|||
#' us <- usa_composite() |
|||
#' us <- sp::spTransform(us, CRS(us_laea_proj)) |
|||
#' us <- usa_composite(proj="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" |
|||
|
|||
|
|||
#' Generic long/lat convenience projection |
|||
#' |
|||
#' The following PROJ.4 string is used: \code{+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0} |
|||
#' |
|||
#' In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
#' parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_longlat_proj)}. |
|||
#' |
|||
#' @export |
|||
#' @examples |
|||
#' us <- usa_composite() # it's the default |
|||
#' us <- sp::spTransform(us, CRS(us_longlat_proj)) |
|||
us_longlat_proj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" |
|||
|
|||
|
|||
#' Lambert conformal conic convenience projection |
|||
#' |
|||
#' The following PROJ.4 string is used: \code{+proj=lcc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875} |
|||
#' |
|||
#' In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
#' parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_lcc_proj)}. |
|||
#' |
|||
#' @family convenience projections |
|||
#' @export |
|||
#' @examples |
|||
#' us <- usa_composite() |
|||
#' us <- sp::spTransform(us, CRS(us_lcc_proj)) |
|||
#' us <- usa_composite(proj="lcc") |
|||
us_lcc_proj <- "+proj=lcc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875" |
|||
|
|||
|
|||
#' Equidistant conic convenience projection |
|||
#' |
|||
#' Distance correct along meridians |
|||
#' |
|||
#' The following PROJ.4 string is used: \code{+proj=eqdc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875} |
|||
#' |
|||
#' In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
#' parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_eqdc_proj)}. |
|||
#' |
|||
#' @family convenience projections |
|||
#' @export |
|||
#' @examples |
|||
#' us <- usa_composite() |
|||
#' us <- sp::spTransform(us, CRS(us_eqdc_proj)) |
|||
#' us <- usa_composite(proj="eqdc") |
|||
#' |
|||
us_eqdc_proj <- "+proj=eqdc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875" |
|||
|
|||
|
|||
#' Oblique azimuthal equidistant convenience projection |
|||
#' |
|||
#' Distance correct along any line passing through the center of the map (i.e., great circle) |
|||
#' |
|||
#' The following PROJ.4 string is used: \code{+proj=aeqd +lat_0=40.08355112574181 +lon_0=-95.44921875} |
|||
#' |
|||
#' In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
#' parameter to \code{ggalt::coord_proj()}. i.e. \code{coord_proj(us_aeqd_proj)}. |
|||
#' |
|||
#' @family convenience projections |
|||
#' @export |
|||
#' @examples |
|||
#' us <- usa_composite() |
|||
#' us <- sp::spTransform(us, CRS(us_aeqd_proj)) |
|||
#' us <- usa_composite(proj="aeqd") |
|||
us_aeqd_proj <- "+proj=aeqd +lat_0=40.08355112574181 +lon_0=-95.44921875" |
|||
|
@ -1,11 +1,45 @@ |
|||
--- |
|||
title: "README" |
|||
author: "@hrbrmstr" |
|||
date: March 28, 2016 |
|||
output: |
|||
html_document: |
|||
keep_md: true |
|||
md_document: |
|||
variant: markdown_github |
|||
--- |
|||
|
|||
albersusa is ... |
|||
`albersusa` : ... |
|||
|
|||
The following functions are implemented: |
|||
|
|||
The following data sets are included: |
|||
|
|||
### Installation |
|||
|
|||
```{r eval=FALSE} |
|||
devtools::install_github("hrbrmstr/albersusa") |
|||
``` |
|||
|
|||
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE} |
|||
options(width=120) |
|||
``` |
|||
|
|||
### Usage |
|||
|
|||
```{r} |
|||
library(albersusa) |
|||
|
|||
# current verison |
|||
packageVersion("albersusa") |
|||
|
|||
``` |
|||
|
|||
### Test Results |
|||
|
|||
```{r} |
|||
library(albersusa) |
|||
library(testthat) |
|||
|
|||
date() |
|||
|
|||
test_dir("tests/") |
|||
``` |
|||
|
|||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -0,0 +1,14 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% 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 |
|||
} |
|||
\author{ |
|||
Bob Rudis (@hrbrmstr) |
|||
} |
|||
|
@ -0,0 +1,30 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/proj.r |
|||
\docType{data} |
|||
\name{us_aeqd_proj} |
|||
\alias{us_aeqd_proj} |
|||
\title{Oblique azimuthal equidistant convenience projection} |
|||
\format{An object of class \code{character} of length 1.} |
|||
\usage{ |
|||
us_aeqd_proj |
|||
} |
|||
\description{ |
|||
Distance correct along any line passing through the center of the map (i.e., great circle) |
|||
} |
|||
\details{ |
|||
The following PROJ.4 string is used: \code{+proj=aeqd +lat_0=40.08355112574181 +lon_0=-95.44921875} |
|||
|
|||
In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
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 <- usa_composite(proj="aeqd") |
|||
} |
|||
\seealso{ |
|||
Other convenience.projections: \code{\link{us_eqdc_proj}}, |
|||
\code{\link{us_laea_proj}}, \code{\link{us_lcc_proj}} |
|||
} |
|||
\keyword{datasets} |
|||
|
@ -0,0 +1,31 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/proj.r |
|||
\docType{data} |
|||
\name{us_eqdc_proj} |
|||
\alias{us_eqdc_proj} |
|||
\title{Equidistant conic convenience projection} |
|||
\format{An object of class \code{character} of length 1.} |
|||
\usage{ |
|||
us_eqdc_proj |
|||
} |
|||
\description{ |
|||
Distance correct along meridians |
|||
} |
|||
\details{ |
|||
The following PROJ.4 string is used: \code{+proj=eqdc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875} |
|||
|
|||
In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
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 <- usa_composite(proj="eqdc") |
|||
|
|||
} |
|||
\seealso{ |
|||
Other convenience.projections: \code{\link{us_aeqd_proj}}, |
|||
\code{\link{us_laea_proj}}, \code{\link{us_lcc_proj}} |
|||
} |
|||
\keyword{datasets} |
|||
|
@ -0,0 +1,28 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/proj.r |
|||
\docType{data} |
|||
\name{us_laea_proj} |
|||
\alias{us_laea_proj} |
|||
\title{Albers equal-area conic convenience projection} |
|||
\format{An object of class \code{character} of length 1.} |
|||
\usage{ |
|||
us_laea_proj |
|||
} |
|||
\description{ |
|||
The following PROJ.4 string is used: \code{+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs} |
|||
} |
|||
\details{ |
|||
In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
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 <- usa_composite(proj="laea") |
|||
} |
|||
\seealso{ |
|||
Other convenience.projections: \code{\link{us_aeqd_proj}}, |
|||
\code{\link{us_eqdc_proj}}, \code{\link{us_lcc_proj}} |
|||
} |
|||
\keyword{datasets} |
|||
|
@ -0,0 +1,28 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/proj.r |
|||
\docType{data} |
|||
\name{us_lcc_proj} |
|||
\alias{us_lcc_proj} |
|||
\title{Lambert conformal conic convenience projection} |
|||
\format{An object of class \code{character} of length 1.} |
|||
\usage{ |
|||
us_lcc_proj |
|||
} |
|||
\description{ |
|||
The following PROJ.4 string is used: \code{+proj=lcc +lat_1=27.11637320883929 +lat_2=53.050729042644335 +lon_0=-95.44921875} |
|||
} |
|||
\details{ |
|||
In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
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 <- usa_composite(proj="lcc") |
|||
} |
|||
\seealso{ |
|||
Other convenience.projections: \code{\link{us_aeqd_proj}}, |
|||
\code{\link{us_eqdc_proj}}, \code{\link{us_laea_proj}} |
|||
} |
|||
\keyword{datasets} |
|||
|
@ -0,0 +1,23 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/proj.r |
|||
\docType{data} |
|||
\name{us_longlat_proj} |
|||
\alias{us_longlat_proj} |
|||
\title{Generic long/lat convenience projection} |
|||
\format{An object of class \code{character} of length 1.} |
|||
\usage{ |
|||
us_longlat_proj |
|||
} |
|||
\description{ |
|||
The following PROJ.4 string is used: \code{+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0} |
|||
} |
|||
\details{ |
|||
In a ggplot2+ggalt context, you can just use variable name as the value for the \code{proj} |
|||
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)) |
|||
} |
|||
\keyword{datasets} |
|||
|
@ -0,0 +1,23 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/albersusa.R |
|||
\name{usa_composite} |
|||
\alias{usa_composite} |
|||
\title{Retreive a U.S. composite map, optionally with a projection} |
|||
\usage{ |
|||
usa_composite(proj = c("longlat", "laea", "lcc", "eqdc", "aeqd")) |
|||
} |
|||
\arguments{ |
|||
\item{proj}{if anything but \code{longlat} is specified, the shapefile will |
|||
be pre-projected before being returned} |
|||
} |
|||
\description{ |
|||
The \code{proj} parameter is intende to simplify usage for those using base |
|||
plotting. If anything but \code{longlat} is specified the composite map |
|||
will be pre-projected to those |
|||
} |
|||
\examples{ |
|||
plot(usa_composite()) |
|||
|
|||
plot(usa_composite("laea")) |
|||
} |
|||
|
@ -0,0 +1,2 @@ |
|||
library(testthat) |
|||
test_check("albersusa") |
@ -0,0 +1,6 @@ |
|||
context("basic functionality") |
|||
test_that("we can do something", { |
|||
|
|||
#expect_that(some_function(), is_a("data.frame")) |
|||
|
|||
}) |
Loading…
Reference in new issue