0

I am looking for a way to regeocode in R using tigris. Is there away to write this into a new data frame and to also add the 2010 census block that was tied to the address?

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

MJ_215
  • 13
  • 2

1 Answers1

0

I never use tigris before. I know that tmaptools can do this task, but without some tags you use the dataframe option.

To solve this situation, I made my our code OpenStreetMap. You can see all the information that you need to build you on this link.

The code that I used is below:

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")
Lori
  • 1,392
  • 1
  • 21
  • 29
GregOliveira
  • 151
  • 10