2014-01-22 26 views
2

我正在尋找使用RGoogleMaps包的GetMap函數將Google API靜態地圖導入到R中。然後我打算使用PlotOnStaticMap將數據點繪製到R中的圖上。我想使用「terrain」maptype,但不希望它上面的標籤。我發現了一個前面的stackoverflow問題,它解決了如何通過使用「style = feature:all | element:labels | visibility:off」來移除地圖上的標籤。將地形類型Google API靜態地圖導入到沒有標籤的R中

地圖用標籤:http://maps.googleapis.com/maps/api/staticmap?center=29.4,-89.2&zoom=9&size=600x500&maptype=terrain&sensor=false

地圖無標籤:http://maps.googleapis.com/maps/api/staticmap?center=29.4,-89.2&zoom=9&size=600x500&maptype=terrain&sensor=false&style=feature:all|element:labels|visibility:off

該第二代碼產生精確地圖我想。但是,當我將它保存爲PNG文件,然後使用GetMaps函數將其導入到R時,它會爲我提供所有仍附加標籤的原始地圖。

有沒有人知道我如何得到沒有標籤正確導入R的地圖?它似乎不應該那麼難,但我還沒有能夠提出解決方案。

謝謝!

代碼在R:

smap<-read.table("D:/sediment/Rfiles/smap.txt", header=TRUE, sep= ""); 
library(RgoogleMaps) 
library(rgdal) 
MyMap <- GetMap(center=c(29.4, -89.2), zoom=9, 
       destfile = "D:/sediment/Rfiles/map.png", maptype="terrain") 
map<-PlotOnStaticMap(MyMap, lat=smap$lat, lon=smap$lon, 
        col=c('black'), add=F,cex=1.1,pch=19) 

* SMAP是緯度,經度的數據文件座標地圖

回答

4

像這種上繪製?

MyMap <- GetMap(center=c(29.4, -89.2), zoom=9, 
       destfile = "D:/sediment/Rfiles/map.png", maptype="terrain", 
       path = "&style=feature:all|element:labels|visibility:off") 
+0

非常感謝!這很好用! – user3225434

相關問題