Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Google satellite view as tile in leaflet with R

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.

like image 560
Xavier Prudent Avatar asked Jun 21 '17 13:06

Xavier Prudent


1 Answers

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")
like image 180
TimSalabim Avatar answered Sep 28 '22 01:09

TimSalabim