为什么我无法使用人口普查块和 lat/long 大纲构建数据框?

Why am I unable to build data frame with census block and lat/long outline?

我是 R 的新手,正在处理人口普查数据,我正在尝试构建一个 csv 文件,该文件可以传递给显示 lat/long 人口普查区块大纲的另一个团队。

有了这个,我可以到达佛罗里达州的 3 个特定人口普查区。

FL_blocks <- blocks("FL", year = 2010, )
FL_blocks_Alachua <- filter(FL_blocks, COUNTYFP == "001")
NTIA_FL_CB <- FL_blocks_Alachua %>%
  filter(FL_blocks_Alachua$GEOID10 %in% c ("120010019071008", "120010019071007", "120010019071009"))

现在我想制作一个 table,只显示 lat/long 和 lat/long 关联的相应人口普查区块。这将为我提供每个人口普查块的 lat/long 列表,我可以用人口普查块的多边形绘制它们,但是为了将其传递给不熟悉 R 的团队,我需要 csv 数据输出。

NTIA_FL_CB_Shape_xy <- as.data.frame(st_coordinates(NTIA_FL_CB$geometry))
NTIA_FL_CB_Shape_xy <- NTIA_FL_CB_Shape_xy %>%
    rename( Longitude = X, Latitude = Y) %>%
    select(Latitude,Longitude )

# save lat/long as csv
st_write(NTIA_FL_CB_Shape_xy, "fl_3cb_ntia_latlong.csv", coords = TRUE)

# plot the 3 census blocks with the outline of the shapefiles marked as green circles
leaflet(NTIA_FL_CB) %>%
  addTiles() %>%
  addPolygons(popup = ~GEOID10) %>%
  addCircleMarkers(data = NTIA_FL_CB_Shape_xy, color = "green")

This image shows what I was thinking, If I could pass the lat/longs outlining each census block the team that uses my csv file output should be able to load that into their GIS software to overlay.

诀窍是投射到点,然后导出。或者,如果您的团队正在使用 GIS 软件,您可以将多面体写入 shapefile 吗?

library(sf)

nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_pt <- st_cast(nc, "POINT")
st_write(nc_pt, "nc_pt.csv", layer_options="GEOMETRY=AS_XY")
# st_write(nc, "nc.shp")

https://gis.stackexchange.com/questions/294921/convert-shapefile-into-lat-long-points-and-export-it-as-csv-in-r