无法在R中的PlotOnStaticMap中绘制负经度值

时间:2018-06-01 12:35:00

标签: r google-maps rgooglemaps

我有:

> df1
          lon      lat grp
1  0.02310676 51.39729   0
2 -0.04666115 51.40614   0
3  0.09730595 51.38398   0
4  0.02458385 51.39580   1

并希望将其绘制在地图上。

library(RgoogleMaps)
> center
[1] 51.389486  0.036657
mm=GetMap(center=center,zoom=10,maptype= "roadmap", destfile = "satellite.png")
PlotOnStaticMap(mm,lat=df1$lat,lon=df1$lon,pch=20,col=df1$grp, cex=2.3)

结果是3个正确放置的标记,缺失的标记是具有负值的标记。 enter image description here 进一步检查:

PlotOnStaticMap(mm,lat=51.40614,lon=0.04666115,pch=20,col=c('red','dark blue'), cex=2.3)

enter image description here 在我想要的地方显示一个红点,但是:

PlotOnStaticMap(mm,lat=51.40614,lon=-0.04666115,pch=20,col=c('red','dark blue'), cex=2.3)

enter image description here 没有任何结果。

非常感谢任何关于如何在西半球包括积分的建议!

1 个答案:

答案 0 :(得分:0)

RgoogleMaps 版本1.4.2似乎不再是问题,该版本已于2018-06-01发布:

library(RgoogleMaps)

## example data
df1 = data.frame(lon = c(0.02310676, -0.04666115, 0.09730595, 0.02458385)
                 , lat = c(51.39729, 51.40614, 51.38398, 51.39580)
                 , grp = c("0", "0", "0", "1"))

center = c(51.389486, 0.036657)

## get google map
dfl = tempfile(fileext = ".png")
mm = GetMap(center, zoom = 12, maptype = "roadmap", destfile = dfl)

## display map with points
par(pty = "s")
PlotOnStaticMap(mm, lat = df1$lat, lon = df1$lon, pch = 20, col = df1$grp, cex = 2.3)

PlotOnStaticMap