Skip to content

Commit

Permalink
update read_spp_range_data() to support multiple shps
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhanson committed Aug 31, 2023
1 parent 60c2a2f commit 2360ad4
Show file tree
Hide file tree
Showing 55 changed files with 320 additions and 277 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: aoh
Type: Package
Version: 0.0.2.6
Version: 0.0.2.7
Title: Create Area of Habitat Data
Description: Create Area of Habitat data to characterize species distributions.
Data are produced following procedures outlined by Brooks et al. (2019)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# aoh 0.0.2.7

- Update `read_spp_range_data()` to that it can import data from a zip
file that contains multiple ESRI Shapefiles (e.g., the 2022-2 IUCN Red List
release for reptile data).

# aoh 0.0.2.6

- Update `create_spp_aoh_data()` and `create_spp_frc_data()` to have a
Expand Down
15 changes: 15 additions & 0 deletions R/read_spp_range_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ read_spp_range_data <- function(path, n = NULL) {
# import data
if (length(shp_path) == 1) {
out <- read_sf_n(shp_path, n = n)
} else if (length(shp_path) > 1) {
## load data
out <- lapply(shp_path, read_sf_n, n = n)
## get column names for each shapefile
nms <- lapply(out, names)
## check that all shapefiles have the same column names
assertthat::assert_that(
all(vapply(nms, FUN.VALUE = logical(1), identical, nms[[1]])),
msg = paste0(
"argument to \"path\" contains multiple shapefiles that have",
"different columns names, and so cannot import spatial data"
)
)
## merge datasets together
out <- dplyr::bind_rows(out)
} else if (length(gdb_path) == 1) { # nocov start
## inspect geodatabase
gdb_dir <- sf::st_layers(gdb_path)
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,7 @@ map <-
strip.text = element_text(color = "white"),
strip.background = element_rect(fill = "black", color = "black")
)
```

## |---------|---------|---------|---------|=========================================

``` r
# display maps
print(map)
```
Expand All @@ -366,7 +362,7 @@ produce Area of Habitat data.
relevant data using:

Hanson JO (2023) aoh: Create Area of Habitat Data. R package version
0.0.2.6. Available at https://github.com/prioritizr/aoh.
0.0.2.7. Available at https://github.com/prioritizr/aoh.

IUCN [insert year] IUCN Red List of Threatened Species. Version
[insert version]. Available at www.iucnredlist.org.
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 14 additions & 18 deletions docs/articles/aoh.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2360ad4

Please sign in to comment.