Reputation: 1732
Many questions seem similar to mine, I could not however find a fitting answer for R.
So far, I use the awesome R leaflet (and ggmap) package that way:
library(ggmap)
library(leaflet)
coord <-geocode('New York')
map.city <- leaflet() %>%
addTiles('http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=68c4cd328d3b484091812a76fae093fd') %>%
setView(coord$lon, coord$lat, zoom = 11)
But what if I want as a map the Google satellite?
I went through this post
https://stackoverflow.com/questions/9394190/leaflet-map-api-with-google-satellite-layer#=
but don't understand how to use the googleSat function defined there.
Upvotes: 11
Views: 10210
Reputation: 26258
To use the actual Google Maps (which comes with satellite view) you can use my googleway
package
library(googleway)
apiKey <- 'your_api_key'
mapKey <- 'your_map_key'
newYork <- google_geocode(address = "New York", key = apiKey)
google_map(location = as.numeric(newYork$results$geometry$location),
key = mapKey)
The vignette has more examples of what you can do with the maps.
Upvotes: 4
Reputation: 5844
If it has to be google satellite imagery you could use the googleway package. If other satellite imagery is ok, you can use "Esri.WorlImagery" with or without "CartoDB.PositronOnlyLabels" in leaflet:
library(ggmap)
library(leaflet)
coord <-geocode('New York')
map.city <- leaflet() %>% addProviderTiles('Esri.WorldImagery') %>%
setView(coord$lon, coord$lat, zoom = 11)
map.city %>% addProviderTiles("CartoDB.PositronOnlyLabels")
Upvotes: 19