I've run a large set of google_reverse_geocode calls through the Google Maps API using the googleway library and I've got a couple of questions.
My initial call is as follows:
loczip <- lapply(seq(nrow(LonLat)), function(i){
google_reverse_geocode(location = c(LonLat$`Centerlat`[i],LonLat$`Center Long`[i]),
result_type=c("street_address"),
location_type="rooftop",
key = "**API KEY HERE**",
simplify = TRUE)
})
Where LonLat is a list with 12,207 observations and 2 variables, Center lat and Center Long. This call is based on an answer I found here
My outputs are in a large list of 12,207 elements. So far I've been having issues exporting this data into a clean format.
I'm wondering if there's a better way to format the output, so instead of a list the values I get are in a data frame or matrix. Baring that, I'm wondering if there's a good way to parse the existing output into a data frame or something similarly useful. My end goal is to export this data to a .csv.
An example of my output is as follows:
> loczipShort[5]
[[1]]
[[1]]$results
address_components
1 1309, South Cushman Avenue, Central Tacoma, Tacoma, Pierce County,
Washington, United States, 98405, 3527, 1309, S Cushman Ave, Central
Tacoma, Tacoma, Pierce County, WA, US, 98405, 3527, street_number,
route, neighborhood, political, locality, political,
administrative_area_level_2, political, administrative_area_level_1,
political, country, political, postal_code, postal_code_suffix
formatted_address geometry.location.lat
geometry.location.lng geometry.location_type
1 1309 S Cushman Ave, Tacoma, WA 98405, USA 47.24899
-122.4566 ROOFTOP
geometry.viewport.northeast.lat geometry.viewport.northeast.lng
geometry.viewport.southwest.lat
1 47.25034 -122.4552
47.24764
geometry.viewport.southwest.lng place_id
types
1 -122.4579 ChIJccNG8BJVkFQRUvDLCQI9Qtc
street_address
[[1]]$status
[1] "OK"
Another complication is that while using the "rooftop" location type there are some outputs that contain "ZERO RESULTS" so I want to make sure I either return an empty row for those, or some other kind of filler so I can clean those out later.
More background about this project: I have paid API access so making the 12k calls isn't the issue. For some reason my account is not set up such that I can use ggmaps and its revgeocode() function, even with ggmaps 2.7, and changing my account status is currently not an option.
Please let me know if there's anything I can clarify, and thank you in advance!
Edit:
df <- structure(list(Longitude = c(-122.4568254, -122.4568254, -122.4568254,
-122.4568254), Latitude = c(47.249256, 47.249256, 47.24917901,
47.24910202)), .Names = c("Longitude", "Latitude"), class = "data.frame", row.names = c(NA,
-4L))
4 sample points from my data. The first two should yield ZERO RESULTS and the second paid should have data. As I understand it the first two have ZERO RESULTS because the points aren't within the "rooftop" range of any canonical address.