2014-01-10 34 views
0

我有一個像R,GGPLOT2和世界地圖點未Hexagone的細胞

X    date   lon  lat 
1 1 2014-01-08 23:50:13 -116.576504 53.93327 
2 2 2014-01-08 23:35:50   NA  NA 
3 3 2014-01-08 23:06:33   NA  NA 
4 4 2014-01-08 23:06:07 -76.670200 39.38100 
5 5 2014-01-08 22:44:37 -77.436048 37.54072 
6 6 2014-01-08 22:35:56 7.189811 43.67342 

數據幀,我想它映射在世界範圍形狀文件,但如果我的觀點可能是六邊形。 ..與ggplot2 ..這將是偉大的! 我不能夠使用geom_hex ...它不會使我想要的... Something like that但帶有下面的世界地圖。一配合物的方法是對的this presentation 22幻燈片,我已經試過

wp<-ggplot()+ 
    geom_polygon(data=word.df,aes(long,lat,group=group))+ 
    geom_path(color="white")+ 
    geom_hex(data=cleanTwittes,aes(lon,lat))+ 
    coord_equal() 

但I'have這個錯誤: 'ERREUR丹斯如果(nrow(layer_data)== 0)()返回:'

感謝的

回答

1

我找到:-)

wp<-ggplot()+ 
    geom_polygon(data=word.df,aes(long,lat,group=group))+ 
    geom_hex(data=cleanTwittes,aes(lon,lat),bins = 55,alpha=8/10)+ 
    theme_bw()+ 
    labs(title = paste(nbTwittes,"twittes entre",minT,"et",maxT, "sur 'terroir'")) 
    coord_equal() 

它使地圖沒有那麼糟糕 enter image description here

但是,如果你有一些消化...