Parit
Parit

Reputation: 55

Converting polygon to sf in R

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!

Upvotes: 2

Views: 803

Answers (1)

eugene100hickey
eugene100hickey

Reputation: 391

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))

Upvotes: 3

Related Questions