谷歌地图在R



我有下面的数据框架,我想用谷歌地图绘制它,因为我已经在谷歌有了一个帐户和API,但我不知道,而且我在其中丢失了很多资源。我得到了(长和拉丁(通过地理编码((已经如下

变量为:Program Credits Univ Location lon lat

有什么建议吗?

Program
2                Master's Programme in Data Science - Data Engineering
3                                       Data Science: Master programme
4                                    Data Science - Master's Programme
5                                    Data Science - Master's Programme
6                                     Master Programme in Data Science
8 Master's Programme in Data Science - Machine Learning and Statistics
Credits                           Univ Location      lon      lat
2     120             Uppsala University  Uppsala 17.63893 59.85856
3     120             Dalarna University Borlänge 15.43397 60.48430
4     120           University of Skövde   Skövde 13.84612 58.39028
5      60           University of Skövde   Skövde 13.84612 58.39028
6      60 Luleå University of Technology    Luleå 22.15670 65.58482
8     120             Uppsala University  Uppsala 17.63893 59.85856

您可以使用leaflet并在OpenStreetMap层上绘制点。使用此软件包,您不需要API或链接帐户。

# Packages
library(dplyr) # to use the pipe operator (magrittr can be used too)
library(leaflet) # acces to openstreetmap layer
library(htmltools) # label each point
# Data
data <-  structure(list(
Univ.location = c( "Uppsala University  Uppsala",
"Dalarna University Borlänge", "University of Skövde   Skövde", 
"University of Skövde   Skövde", "University of Technology    Luleå", 
"Uppsala University  Uppsala"),
lon = c(17.63893, 15.43397, 13.84612, 
13.84612, 22.1567, 17.63893),
lat = c(59.85856, 60.4843, 58.39028, 
58.39028, 65.58482, 59.85856)),
class = "data.frame", row.names = c(NA, -6L))
# Map

data %>% 
leaflet() %>% 
addTiles() %>% 
addCircleMarkers( label = ~htmlEscape(Univ.location))

这里有一个有用的文件

相关内容

  • 没有找到相关文章

最新更新