0

我正在寻找一种使用 tigris 在 R 中重新编码的方法。是否可以将其写入新数据框并添加与地址相关的 2010 年人口普查块?

机场 <- dplyr::data_frame( street = "700 Catalina Dr", city = "Daytona Beach", state = "FL") append_geoid(airports, 'block')

4

1 回答 1

0

我以前从没用过底格里斯河。我知道 tmaptools 可以完成这项任务,但没有一些标签,您可以使用 dataframe 选项。

为了解决这种情况,我制作了我们的代码OpenStreetMap。您可以在此链接上查看构建您所需的所有信息。

我使用的代码如下:

x <- 1:370

address_tidy <- tibble(
    accident_index = "accidents_tidy$accident_index[i]",
    geo_loc = "accidents_tidy$geo_loc[i]",
    xml.names = "(xml_name(xml_children(xml_children(open_map_xml))))",
    xml.text = "(xml_text(xml_children(xml_children(open_map_xml))))"
  )

address_tidy <- address_tidy %>%
  filter(accident_index == "Greg")

for (i in x) {
  open_map_url <- str_c(
    "https://nominatim.openstreetmap.org/search?q=",
    accident_index_loc_$geo_loc[i],
    "&format=xml&polygon=0&addressdetails=1"
  )
  
  open_map_xml <- read_xml(open_map_url)
  
  df <- tibble(
    accident_index = accident_index_loc_$accident_index[i],
    geo_loc = accident_index_loc_$geo_loc[i],
    xml.names = (xml_name(xml_children(xml_children(open_map_xml)))),
    xml.text = (xml_text(xml_children(xml_children(open_map_xml))))
  )
  
  address_tidy <- bind_rows(address_tidy, df)
  
}

write.csv(address_tidy, "address_tidy_part10.csv")
于 2021-12-15T00:55:22.337 回答