如何将openstreetmap与R中的点组合

如何将openstreetmap与R中的点组合,r,graphics,ggplot2,ggmap,R,Graphics,Ggplot2,Ggmap,我刚开始学习R,我正试图创建一张地图,显示康涅狄格州每个城镇的学生人数。我有一个.csv的位置和注册信息,如下所示: name lon lat resStudent 1 ANDOVER -72.37472 41.73278 657 2 ANSONIA -73.07900 41.34621 2999 3 ASHFORD -72.12162 41.87307 736 4

我刚开始学习R,我正试图创建一张地图,显示康涅狄格州每个城镇的学生人数。我有一个.csv的位置和注册信息,如下所示:

name       lon      lat resStudent
1   ANDOVER          -72.37472 41.73278        657
2   ANSONIA          -73.07900 41.34621       2999
3   ASHFORD          -72.12162 41.87307        736
4   AVON             -72.83052 41.80962       3563
5   BARKHAMSTED      -72.97222 41.92917        680
6   BEACON FALLS     -73.06176 41.44265       1039
7   BERLIN           -72.78064 41.61460       3165
8   BETHANY          -72.99250 41.42556       1028
9   BETHEL           -73.41396 41.37123       3034
10  BETHLEHEM        -73.20861 41.63917        490
11  BLOOMFIELD       -72.73336 41.83945       2484
我已经能够使用以下代码生成要覆盖此信息的地图:

tempMap <- get_openstreetmap(bbox = c(left = -73.8, bottom = 40.9, right = -71.7, top = 42.1), scale = 829486, color = "bw")
ggmap(tempMap)

关于如何解决这个问题有什么想法吗?

您需要调用
ggmap
首先创建基础层。以下方面应起作用:

ggmap(tempMap) + geom_point(data = enrollData,aes(x = lon, y = lat, size = resStudent)

你试过了吗:
ggmap(tempMap)+geom_point(data=enrollData,aes(x=lon,y=lat,size=restudent)
?现在可以工作了-谢谢!酷!有截图吗?这是一个使用cloudmap而不是openstreetmap的截图:
Error in Ops.raster(tempMap, geom_point(data = enrollData, aes(x = lon,  : 
  Operator not meaningful for raster objects
ggmap(tempMap) + geom_point(data = enrollData,aes(x = lon, y = lat, size = resStudent)