Converting polygon to sf in R

浪子不回头ぞ 提交于 2021-01-27 21:07:24

问题


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:


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


来源:https://stackoverflow.com/questions/63080610/converting-polygon-to-sf-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!