1

I am trying to plot the nearest Walmart store in Canada to a certain post code using ggmap. The function used to get the location is:

goodPoint<-geocode("M1L2K1 walmart canada")

This returned the lat and lon:

> goodPoint
       lon      lat
1    -79.30113  43.72304

When I check Google map search using the same search term and get the latitude and longitude I get 43.728933,-79.29565.

The difference between the returned latitude and longitude is about 1.1 km, so quite significant.

Can anyone suggest why there is this difference when in the documentation it states that it uses Google Maps for the location? Any suggestions for ways around this?

j0k
  • 22,600
  • 28
  • 79
  • 90
gabrown86
  • 1,719
  • 3
  • 12
  • 18

1 Answers1

1

Have you looked at the actual output from Google geocoder? The geocoder is not the same thing as the maps search. The geocoder resolves addresses, but it afaict does not perform searches such as "find a walmart near M1L2K1 canada".

https://maps.googleapis.com/maps/api/geocode/json?address=M1L2K1%20walmart%20canada&sensor=false

yields the following parsed address:

"formatted_address" : "Scarborough, Ontario M1L 2K1, Kanada"
...
"location_type" : "APPROXIMATE",
...
"types" : [ "postal_code" ]

So in fact, Google even tells you that this is a "postal code resolution" geocoding.

Again, geocoding does not equal search. "Walmart" is not a postal address, but a reasonable search term.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194