r - 向 RgoogleMaps 图添加点

标签 r plot rgooglemaps

我正在使用 R 的包 RgoogleMaps。我已经绘制了我的 map ,我需要使用 points 命令添加点,但它不起作用.这是我的代码:

PlotOnStaticMap(Map, add = FALSE, TrueProj=F,  FUN = points)    # plot the background

# add external boundary

for (nb in 1:100)
{
    points(x[nb],y[nb],type="l",lwd=3)
}

我该如何解决?

最佳答案

我想这就是您要找的:

lat = c(40.702147,40.718217,40.711614);
lon = c(-74.012318,-74.015794,-73.998284);
center = c(mean(lat), mean(lon));
zoom <- min(MaxZoom(range(lat), range(lon)));


Map <- GetMap(center=center, zoom=zoom,markers = paste0("&markers=color:blue|label:S|",                                                      
                                                          "40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=",
                                                          "color:red|color:red|label:C|40.718217,-73.998284"), destfile = "MyTile1.png");





tmp <- PlotOnStaticMap(Map, lat = c(40.702147,40.711614,40.718217), 
                       lon = c(-74.015794,-74.012318,-73.998284), 
                       destfile = "MyTile1.png", cex=1.5,pch=20,                       
                       col=c('red', 'blue', 'green'), add=FALSE);


# Now let's add points with the points method:

PlotOnStaticMap(Map, lat = c(40.702147,40.711614,40.718217), 
                lon = c(-74.015794,-74.012318,-73.998284), 
                lwd=1.5,col=c('red', 'blue', 'green'),  points(x = 40.702148, y = NULL ), add=TRUE)

查看 PlotOnStaticMappoints() 的语法?

关于r - 向 RgoogleMaps 图添加点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27360265/

相关文章:

r - 从 mtable/outreg-type 表中省略一些系数

r - 将 Rmath.h 中的 pnorm 与 Rcpp 一起使用

matlab - 如何用三个变量绘制多维数组

python - 将 xarray.plot.line 与颜色图结合使用

r - 如何将 RgoogleMaps PNG 转换为 R 中的 SpatialGridDataFrame?

r - 使用 R 将 basemap 添加到 SpatialPointDataFrames

r - fread 无法读取第一列为空的 .csv 文件

r - 从 R 中的函数在数据框中创建新列

r - 如何使用我选择的颜色在 R 中按组绘制?

linux - readChar 错误(con,5L,useBytes = TRUE): cannot open the connection