Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25b4830

Browse files
committed
Merge branch 'master' ofhttps://github.com/mikejohnson51/AOI
2 parentsbec399e +6b0a52a commit25b4830

File tree

6 files changed

+49
-29
lines changed

6 files changed

+49
-29
lines changed

‎.github/workflows/R-CMD-check.yaml‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ jobs:
2929
-{os: macOS-latest, r: 'release'}
3030
-{os: windows-latest, r: 'release'}
3131
-{os: windows-latest, r: '3.6'}
32-
-{os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
33-
-{os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
34-
-{os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
35-
-{os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
36-
-{os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
37-
-{os: ubuntu-18.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
38-
32+
-{os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
33+
-{os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
34+
-{os: ubuntu-20.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
35+
-{os: ubuntu-20.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
3936
env:
4037
R_REMOTES_NO_ERRORS_FROM_WARNINGS:true
4138
RSPM:${{ matrix.config.rspm }}
@@ -77,7 +74,9 @@ jobs:
7774
-name:Install dependencies
7875
run:|
7976
remotes::install_deps(dependencies = TRUE)
77+
remotes::install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
8078
remotes::install_cran("rcmdcheck")
79+
remotes::install_cran("sessioninfo")
8180
shell:Rscript {0}
8281

8382
-name:Session info

‎.github/workflows/pkgdown.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
-name:Install dependencies
3636
run:|
3737
remotes::install_deps(dependencies = TRUE)
38+
install.packages("rgeos")
39+
install.packages("USAboundariesData", repos = "http://packages.ropensci.org", type = "source")
40+
install.packages("kableExtra")
3841
install.packages("pkgdown", type = "binary")
3942
shell:Rscript {0}
4043

‎.github/workflows/test-coverage.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ jobs:
4444
shell:Rscript {0}
4545

4646
-name:Test coverage
47-
run:covr::coveralls()
47+
run:covr::coveralls(service_name = "github-actions", quiet = FALSE)
4848
shell:Rscript {0}

‎R/aoi_get.R‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@
123123
#' }
124124
#'
125125
aoi_get<-function(x=NULL,country=NULL,state=NULL,
126-
county=NULL,km=FALSE,union=FALSE) {
126+
county=NULL,fip=NULL,
127+
km=FALSE,union=FALSE) {
127128

128129
# Error Catching
129130

@@ -148,7 +149,7 @@ aoi_get <- function(x = NULL, country = NULL, state = NULL,
148149
"ALL"
149150
))) {
150151
stop(paste(
151-
"State notrecongized.",
152+
"State notrecognized.",
152153
"Full names, regions, or abbreviations can be used."
153154
))
154155
}
@@ -157,15 +158,15 @@ aoi_get <- function(x = NULL, country = NULL, state = NULL,
157158
if (!is.null(county)) {
158159
stop("The use of 'county' requires a 'state' parameter.")
159160
}
160-
if (is.null(x)) {
161-
stop("Requiresa 'x' or 'state' parameter to execute.")
161+
if (is.null(x)& is.null(fip)) {
162+
stop("Requiresan 'x' or 'state' parameter to execute.")
162163
}
163164
}
164165
}
165166

166167
# Fiat Boundary Defintion (Exisiting Spatial/Raster Feature or getFiat())
167168
shp<-if (is.null(x)) {
168-
getFiat(country=country,state=state,county=county)
169+
getFiat(country=country,state=state,county=county,fip=fip)
169170
}elseif (any(
170171
methods::is(x,"Raster"),
171172
methods::is(x,"Spatial"),

‎R/getFiat.R‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@
3333
#'
3434
#' @author Mike Johnson
3535

36-
getFiat<-function(country=NULL,state=NULL,county=NULL) {
37-
map0<-map1<-map2<-map3<-NULL
36+
getFiat<-function(country=NULL,state=NULL,county=NULL,fip=NULL) {
37+
map0<-map1<-map2<-map3<-map4<-NULL
3838

39-
find<-function(x,vec,full) {
40-
full[tolower(vec)%in% tolower(x)]
41-
}
39+
find<-function(x,vec,full) {full[tolower(vec)%in% tolower(x)] }
4240

4341
if (!is.null(country)) {
4442
countries<-rnaturalearth::ne_countries(returnclass="sf") %>%
@@ -131,28 +129,47 @@ getFiat <- function(country = NULL, state = NULL, county = NULL) {
131129
}
132130
}
133131

132+
if(!is.null(fip)){
133+
if(!nchar(fip)%in% c(2,5)){
134+
stop("FIP codes must be of length 2,3 or 5")
135+
}
136+
137+
if(nchar(fip)==2){
138+
map4<-USAboundaries::us_states()
139+
map4<-map4[map4$statefp==fip,] %>%
140+
sf::st_transform(4269)
141+
}else {
142+
map4<-USAboundaries::us_counties()
143+
map4<-map4[map4$geoid==fip,] %>%
144+
sf::st_transform(4269)
145+
}
146+
147+
148+
}
149+
150+
151+
134152
map<- tryCatch(
135153
{
136-
rbind(map0,map1,map2,map3)
154+
rbind(map0,map1,map2,map3,map4)
137155
},
138156
error=function(e) {
139157
if (!is.null(map0)) {
140-
map0<-dplyr::mutate(map0,"NAME"=map0$name) %>%
141-
dplyr::select("NAME")
158+
map0<-dplyr::select(map0,"NAME"=map0$name)
142159
}
143160
if (!is.null(map1)) {
144-
map1<-dplyr::mutate(map1,"NAME"=map1$name) %>%
145-
dplyr::select("NAME")
161+
map1<-dplyr::select(map1,"NAME"=map1$name)
146162
}
147163
if (!is.null(map2)) {
148-
map2<-dplyr::mutate(map2,"NAME"=map2$state_name) %>%
149-
dplyr::select("NAME")
164+
map2<-dplyr::select(map2,"NAME"=map2$state_name)
165+
}
166+
if (!is.null(map3)) {
167+
map3<-dplyr::select(map3,"NAME"=map3$name)
150168
}
151169
if (!is.null(map3)) {
152-
map3<-dplyr::mutate(map3,"NAME"=map3$name) %>%
153-
dplyr::select("NAME")
170+
map3<-dplyr::select(map3,"NAME"=map4$name)
154171
}
155-
rbind(map1,map2,map3)
172+
rbind(map1,map2,map3,map4)
156173
}
157174
)
158175

‎tests/testthat/test_aoi.R‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_that("aoi_get errors...", {
1313

1414
expect_error(
1515
aoi_get(state="TweedleDee"),
16-
"State notrecongized. Full names, regions, or abbreviations can be used."
16+
"State notrecognized. Full names, regions, or abbreviations can be used."
1717
)
1818

1919
expect_error(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp