Skip to content

Commit

Permalink
fix bug in reading IUCN 2022-2 reptile data
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhanson committed Aug 31, 2023
1 parent 2360ad4 commit a9f7750
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/read_spp_range_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,20 @@ read_spp_range_data <- function(path, n = NULL) {
} else if (length(shp_path) > 1) {
## load data
out <- lapply(shp_path, read_sf_n, n = n)
## remove uneeded columns
out <- lapply(
out,
function(x) {
n <- setdiff(names(x), c("OBJECTID", attr(x, "sf_column")))
x[, n, drop = FALSE]
}
)
## 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(
msg = paste(
"argument to \"path\" contains multiple shapefiles that have",
"different columns names, and so cannot import spatial data"
)
Expand Down

0 comments on commit a9f7750

Please sign in to comment.