Xav*_*ent 3 google-maps r satellite-image leaflet ggmap
许多问题看起来与我的相似,但我无法找到适合的答案.
到目前为止,我使用了令人敬畏的R传单(和ggmap)包:
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)
Run Code Online (Sandbox Code Playgroud)
但是,如果我想将谷歌卫星作为地图呢?
我仔细阅读了这篇文章
但不明白如何使用那里定义的googleSat函数.
如果它必须是谷歌卫星图像,你可以使用googleway包.如果其他卫星图像没问题,您可以在传单中使用"Esri.WorlImagery",有或没有"CartoDB.PositronOnlyLabels":
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")
Run Code Online (Sandbox Code Playgroud)
要使用实际的 Google 地图(带有卫星视图),您可以使用我的googleway包
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)
Run Code Online (Sandbox Code Playgroud)
小插图提供了更多有关如何使用地图进行操作的示例。