Closed jcrodriguez1989 closed 3 years ago
The radius
argument is expecting metres, so you're searching a 48.28 metre radius. This probably isn't what you're intending?
thanks for your reply, that was an issue I had :) I've tried now:
res <- list(next_page_token = NULL)
places <- list()
i <- 0
while ("next_page_token" %in% names(res)) {
res <- googleway::google_places(
location = c(33.90666, -116.549327),
radius = 30 * 1.60934 * 1000, # 30 miles to meters.
language = "en",
key = api_key,
page_token = res$next_page_token
)
print(res$status)
i <- i + 1
places[[i]] <- res
}
And it still retrieves too few results, only 60 rows (in total). And just 2 of them are localities.
When you say "every locality", do you mean the locality
type as per Google's definition ?
If so you can specify this type in the place_type
argument.
Exactly, I also did it. but just 2 results.
places <- googleway::google_places(
location = c(33.90666, -116.549327),
radius = 30 * 1.60934 * 1000, # 30 miles to meters.
language = "en",
key = api_key,
place_type = "locality"
)
It seems something is not working as expected xD
The url generated by your query is
https://maps.googleapis.com/maps/api/place/nearbysearch/json?&location=33.90666,-116.549327&radius=48280.2&language=en&type=locality&key=
Which as far as I can tell is correct according to google's example
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY
so I don't really know why you're getting two results.
Thank you very much! I am new to the GMaps API, so all I wanted to know was if I was missing something.
My next try is to manually define a grid of several (lat, long) points, and start using the google_reverse_geocode
for each point in the grid. Do you have any comments about this idea? Any better approach you would try?
Thanks for your help! I really appreciate it.
If you're searching in the US there may be other packges which contain US-specific data, like tidycensus, which will give you boundaries and areas. This might have what you're looking for, and shouldn't cost anything.
Yup, that would be a great idea, but I need the exact Google locality
names 🤦♂️
thanks!
Thank you very much @dcooley , the grid approach did work. Excellent package!
I am running:
but my
places$results
has only 4 rows, of which just one is a locality. However, if I check here there are much more localities within 30miles.thanks!