简体   繁体   English

在 R 中将多边形转换为 sf

[英]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.使用这里的教程: https://www.r-spatial.org/r/2018/10/25/ggplot2-sf-2.html (在名为“状态(多边形数据)”的部分),我正在尝试将多边形转换为 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我收到错误消息: Error in as_mapper(.f, ...): argument ".f" is missing, with no default

Thank you in advance!先感谢您!

Looks like it's confusing map() from the purrr package with map() from the maps package.看起来它混淆了purrr package 中的map() map() maps package 中的 map()。 Try:尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM