@ -1,2 +1,5 @@ |
|||
0.3.0 |
|||
* simplefeatures (sf) functions |
|||
|
|||
0.1.0 |
|||
* Initial release |
|||
|
@ -0,0 +1,62 @@ |
|||
#' Retreive a U.S. county composite map, optionally with a projection, as a simplefeature |
|||
#' |
|||
#' 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 |
|||
#' |
|||
#' This is what's in the object looks like: |
|||
#' |
|||
#' \preformatted{ |
|||
#' Observations: 3,143 |
|||
#' Variables: 9 |
|||
#' $ fips <fctr> 01001, 01009, 01017, 01021, 01033, 01045, 01051, 01065, 01079, 0... |
|||
#' $ state_fips <fctr> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 05, 05, 06, ... |
|||
#' $ county_fips <fctr> 001, 009, 017, 021, 033, 045, 051, 065, 079, 083, 099, 107, 121,... |
|||
#' $ name <fctr> Autauga, Blount, Chambers, Chilton, Colbert, Dale, Elmore, Hale,... |
|||
#' $ lsad <fctr> County, County, County, County, County, County, County, County, ... |
|||
#' $ census_area <dbl> 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485, 64... |
|||
#' $ state <fctr> Alabama, Alabama, Alabama, Alabama, Alabama, Alabama, Alabama, A... |
|||
#' $ iso_3166_2 <fctr> AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AR, AR, CA, ... |
|||
#' $ geometry <simple_feature> MULTIPOLYGON(((-86.496774 3..., MULTIPOLYGON(((-86.577...#' } |
|||
#' |
|||
#' 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 |
|||
#' library(sf) |
|||
#' |
|||
#' plot(counties_sf()) # these take a while to render |
|||
#' plot(counties_sf("laea")) |
|||
counties_sf <- function(proj=c("longlat", "laea", "lcc", "eqdc", "aeqd")) { |
|||
|
|||
# us <- readOGR(system.file("extdata/composite_us_counties.geojson", package="albersusa"), |
|||
# "OGRGeoJSON", |
|||
# stringsAsFactors=FALSE, |
|||
# verbose=FALSE) |
|||
|
|||
cty <- readRDS(system.file("extdata/counties_sf.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) |
|||
|
|||
cty <- sf::st_transform(cty, proj) |
|||
|
|||
} |
|||
|
|||
cty |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
#' Retreive a U.S. state composite map, optionally with a projection, as a simplefeature |
|||
#' |
|||
#' 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 |
|||
#' |
|||
#' This is what's the object looks like: |
|||
#' |
|||
#' \preformatted{ |
|||
#' Observations: 51 |
|||
#' Variables: 14 |
|||
#' $ geo_id <fctr> 0400000US04, 0400000US05, 0400000US06, 0400000US08, 0400... |
|||
#' $ fips_state <fctr> 04, 05, 06, 08, 09, 11, 13, 17, 18, 22, 27, 28, 30, 35, ... |
|||
#' $ name <fctr> Arizona, Arkansas, California, Colorado, Connecticut, Di... |
|||
#' $ lsad <fctr> , , , , , , , , , , , , , , , , , , , , , , , , , , , , , |
|||
#' $ census_area <dbl> 113594.084, 52035.477, 155779.220, 103641.888, 4842.355, ... |
|||
#' $ iso_3166_2 <fctr> AZ, AR, CA, CO, CT, DC, GA, IL, IN, LA, MN, MS, MT, NM, ... |
|||
#' $ census <int> 6392017, 2915918, 37253956, 5029196, 3574097, 601723, 968... |
|||
#' $ pop_estimataes_base <int> 6392310, 2915958, 37254503, 5029324, 3574096, 601767, 968... |
|||
#' $ pop_2010 <int> 6411999, 2922297, 37336011, 5048575, 3579345, 605210, 971... |
|||
#' $ pop_2011 <int> 6472867, 2938430, 37701901, 5119661, 3590537, 620427, 981... |
|||
#' $ pop_2012 <int> 6556236, 2949300, 38062780, 5191709, 3594362, 635040, 991... |
|||
#' $ pop_2013 <int> 6634997, 2958765, 38431393, 5272086, 3599341, 649111, 999... |
|||
#' $ pop_2014 <int> 6731484, 2966369, 38802500, 5355866, 3596677, 658893, 100... |
|||
#' $ geometry <list> [-112.53859, -112.53454, -112.36895, -112.35769, -111.41...#' } |
|||
#' |
|||
#' 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 |
|||
#' library(sf) |
|||
#' |
|||
#' plot(usa_sf()) # these take a while to render |
|||
#' plot(usa_sf("laea")) |
|||
usa_sf <- 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_sf.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 <- sf::st_transform(us, proj) |
|||
|
|||
} |
|||
|
|||
us |
|||
|
|||
} |
After Width: | Height: | Size: 213 KiB |
After Width: | Height: | Size: 538 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 177 KiB |
After Width: | Height: | Size: 273 KiB |
After Width: | Height: | Size: 296 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 348 KiB |
After Width: | Height: | Size: 324 KiB |
After Width: | Height: | Size: 341 KiB |
After Width: | Height: | Size: 340 KiB |
After Width: | Height: | Size: 333 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 143 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 133 KiB |
@ -0,0 +1,47 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/counties_sf.r |
|||
\name{counties_sf} |
|||
\alias{counties_sf} |
|||
\title{Retreive a U.S. county composite map, optionally with a projection, as a simplefeature} |
|||
\usage{ |
|||
counties_sf(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 |
|||
} |
|||
\details{ |
|||
This is what's in the object looks like: |
|||
|
|||
\preformatted{ |
|||
Observations: 3,143 |
|||
Variables: 9 |
|||
$ fips <fctr> 01001, 01009, 01017, 01021, 01033, 01045, 01051, 01065, 01079, 0... |
|||
$ state_fips <fctr> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 05, 05, 06, ... |
|||
$ county_fips <fctr> 001, 009, 017, 021, 033, 045, 051, 065, 079, 083, 099, 107, 121,... |
|||
$ name <fctr> Autauga, Blount, Chambers, Chilton, Colbert, Dale, Elmore, Hale,... |
|||
$ lsad <fctr> County, County, County, County, County, County, County, County, ... |
|||
$ census_area <dbl> 594.436, 644.776, 596.531, 692.854, 592.619, 561.150, 618.485, 64... |
|||
$ state <fctr> Alabama, Alabama, Alabama, Alabama, Alabama, Alabama, Alabama, A... |
|||
$ iso_3166_2 <fctr> AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AR, AR, CA, ... |
|||
$ geometry <simple_feature> MULTIPOLYGON(((-86.496774 3..., MULTIPOLYGON(((-86.577...#' } |
|||
|
|||
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{ |
|||
library(sf) |
|||
|
|||
plot(counties_sf()) # these take a while to render |
|||
plot(counties_sf("laea")) |
|||
} |
|||
|
@ -0,0 +1,52 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/states_sf.r |
|||
\name{usa_sf} |
|||
\alias{usa_sf} |
|||
\title{Retreive a U.S. state composite map, optionally with a projection, as a simplefeature} |
|||
\usage{ |
|||
usa_sf(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 |
|||
} |
|||
\details{ |
|||
This is what's the object looks like: |
|||
|
|||
\preformatted{ |
|||
Observations: 51 |
|||
Variables: 14 |
|||
$ geo_id <fctr> 0400000US04, 0400000US05, 0400000US06, 0400000US08, 0400... |
|||
$ fips_state <fctr> 04, 05, 06, 08, 09, 11, 13, 17, 18, 22, 27, 28, 30, 35, ... |
|||
$ name <fctr> Arizona, Arkansas, California, Colorado, Connecticut, Di... |
|||
$ lsad <fctr> , , , , , , , , , , , , , , , , , , , , , , , , , , , , , |
|||
$ census_area <dbl> 113594.084, 52035.477, 155779.220, 103641.888, 4842.355, ... |
|||
$ iso_3166_2 <fctr> AZ, AR, CA, CO, CT, DC, GA, IL, IN, LA, MN, MS, MT, NM, ... |
|||
$ census <int> 6392017, 2915918, 37253956, 5029196, 3574097, 601723, 968... |
|||
$ pop_estimataes_base <int> 6392310, 2915958, 37254503, 5029324, 3574096, 601767, 968... |
|||
$ pop_2010 <int> 6411999, 2922297, 37336011, 5048575, 3579345, 605210, 971... |
|||
$ pop_2011 <int> 6472867, 2938430, 37701901, 5119661, 3590537, 620427, 981... |
|||
$ pop_2012 <int> 6556236, 2949300, 38062780, 5191709, 3594362, 635040, 991... |
|||
$ pop_2013 <int> 6634997, 2958765, 38431393, 5272086, 3599341, 649111, 999... |
|||
$ pop_2014 <int> 6731484, 2966369, 38802500, 5355866, 3596677, 658893, 100... |
|||
$ geometry <list> [-112.53859, -112.53454, -112.36895, -112.35769, -111.41...#' } |
|||
|
|||
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{ |
|||
library(sf) |
|||
|
|||
plot(usa_sf()) |
|||
plot(usa_sf("laea")) |
|||
} |
|||
|