Converting polygon to sf in R

Viewed 305

Using the tutorial here: https://www.r-spatial.org/r/2018/10/25/ggplot2-sf-2.html (in the section called "States (polygon data)"), I'm trying to convert polygons to an sf object.

library("maps")

states <- st_as_sf(map("state", plot = FALSE, fill = TRUE))
head(states)

I get the error message: Error in as_mapper(.f, ...) : argument ".f" is missing, with no default

Thank you in advance!

1 Answers

Looks like it's confusing map() from the purrr package with map() from the maps package. Try:

states <- st_as_sf(maps::map("state", plot = FALSE, fill = TRUE))
Related