ggmap store locations (complete list)


I'm trying to use ggmap to find all Krogers in Houston.

geocode(location = "Kroger, Houston TX", output = "more", source = "google")

Yet, I'm getting only a one-row output:

# A tibble: 1 x 9 lon lat type loctype address north south east west <dbl> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 -95.6 29.9 establishment rooftop 9125 west sam houston pkwy n, houston, tx 77064, usa 29.9 29.9 -95.6 -95.6

Does anyone know why is this happening and how can I get a complete list?


The geocode() function is meant for getting coordinates of a specific point; it is not a good use case for obtaining all locations of a particular store.

You could in theory be able to get the data by accessing Google Places API directly (it is a REST API, so it plays nicely with {httr}) but Google is getting all sorts of bad rep recently (to get an idea why do check out their Terms & Conditions). I am not aware of a package wrapper for the API.

I suggest you consider Open Street Map as an data source instead.

Consider this code, built on the excellent {osmdata} package:


# get all types of results / polygons, points, lines as a list
search_res <- opq(bbox = "Houston, TX") %>%
  add_osm_feature(key = "name", value = "Kroger") %>%

# select the points returned
kroger_points <- search_res$osm_points %>%

# draw a map as a reality check
leaflet() %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addCircleMarkers(data = kroger_points,
                   fillColor = "red",
                   stroke = F,
                   label = ~ name)

1 Like

Thanks very much for this response, it has been very useful. I just have one follow up question:

Is there a reason why the function does not detect all Kroger? Although it performs almost perfectly, it seems that there are some cases that it couldn't identify.

The function knows only those Kroger's that have an entry on OpenStreetMap - so the quality of output fully reflects OSM data. For good or bad.

The Google places is a separate data source and it is quite possible for the two to differ.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.