Search code examples
rggplot2ggmap

Error while creating a new york city map with get_map Function


I have been trying to plot a map of locations of different types of buildings that consume natural gas in the New York city

I tried to download the map of New York with get_map function

map <- get_map(location ="New York", maptype = "terrain",
         source='google',color='color')

When I try this I keep getting this error

Error in data.frame(ll.lat = ll[1], ll.lon = ll[2], ur.lat = ur[1], ur.lon = ur[2]) : arguments imply differing number of rows: 0, 1

How do I retify this error?

I also tried to use latitude and longitude locations doesn't seem to work either


Solution

  • I had this problem for a long time. Drove me nuts. Sometimes it worked by itself, sometimes it didn't. Even after updating all the packages. I was using rmarkdown with caching enabled.

    I think I found the issue. It is due to caching in the hidden object .GeocodedInformation.

    Now I placed this before my code and I don't see the error anymore:

    if (exists('.GeocodedInformation')) rm(.GeocodedInformation)