通过使用城市和州来绘制ggmap [英] Plot on ggmap by using city and state
问题描述
我有一张美国地图,准备出发:
mygggmap< - get_map(location =United States,zoom = 4)
g < - ggmap(myggmap)
下一步是绘制一些主要城市。
我知道我可以创建一个图层来绘制我的主要城市的经度和纬度,如下所示: 但我想知道是否有办法按实际名称,城市和州来绘图?由于ggmap是通过Google Map API分层的,这应该是可能的,是正确的吗? 我找到了答案。很简单。使用地理编码功能: 返回 感谢大家的支持。尽管我刚收到'风滚草'徽章。 I have a map of the USA, ready to go: The next step is to plot some major cities. I understand I can create a layer to plot my major cities by their longitude and latitude, something like: but I am wondering if there is a way to plot by the actual name, city and state? Since ggmap is layered over the Google Map API, this should be possible, correct? I found the answer. It is simple. Use the geocode function: returns Thanks for the support everyone. Even though I just got a 'tumbleweed' badge. 这篇关于通过使用城市和州来绘制ggmap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
g < - g + geom_density2d(data = citydata,aes(x = lon,y = lat))
geocode(SEATTLE)
lon lat
-122.3321 47.60621
mygggmap <- get_map(location = "United States", zoom = 4)
g <- ggmap(myggmap)
g <- g + geom_density2d(data = citydata, aes(x = lon, y = lat))
geocode("SEATTLE")
lon lat
-122.3321 47.60621