Skip to content

Commit 2b0af7e

Browse files
authored
Fix tibble dependency issue in read_sf() (#52)
### Changes <!-- List the changes made by the pull request and rationale where applicable --> * Set `as_tibble = FALSE` in `create_us_map()`, `us_map()`, and `centroid_labels()` ### Notes <!-- List any other related notes, e.g. how to test the changes or any known issues --> * This change is due to `ggplot2` no longer importing `tibble` by default (now a Suggests). * tidyverse/ggplot2#5990 * For the purposes of this package, reading the simple features data as a data frame is suitable. * Any package consumers that require tibbles can easily convert them using `tibble:as_tibble()`. * Originally reported in `usmap`: pdil/usmap#117 <!-- Include the issue number here if applicable --> resolves #53
2 parents b3f18b3 + 527e739 commit 2b0af7e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# [unreleased]
22

3+
* Change output of `us_map()` and `centroid_labels()` to data frame instead of tibble.
4+
* If `tibble` format is required use `tibble:as_tibble()`.
5+
36
# usmapdata 0.5.0
47
Released Thursday, May 22, 2025.
58

R/create-us-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ create_us_map <- function(
6060
type <- match.arg(type)
6161

6262
# import map file
63-
us <- sf::read_sf(input_file)
63+
us <- sf::read_sf(input_file, as_tibble = FALSE)
6464

6565
# ea: US National Atlas Equal Area
6666
us_ea <- sf::st_transform(us, ea_crs())

R/us-map.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ us_map <- function(
5151
map_year <- select_map_year(data_year)
5252
file_name <- paste0("us_", regions, ".gpkg")
5353
file_path <- system.file("extdata", map_year, file_name, package = "usmapdata")
54-
df <- sf::read_sf(file_path)
54+
df <- sf::read_sf(file_path, as_tibble = FALSE)
5555

5656
if (length(include) > 0) {
5757
df <- df[df$full %in% include |
@@ -91,7 +91,7 @@ centroid_labels <- function(
9191
file_name <- paste0("us_", regions, "_centroids.gpkg")
9292
file_path <- system.file("extdata", map_year, file_name, package = "usmapdata")
9393

94-
sf::read_sf(file_path)
94+
sf::read_sf(file_path, as_tibble = FALSE)
9595
}
9696

9797
#' Years for which US map data is available

0 commit comments

Comments
 (0)