Plot coordinates on map

前端 未结 4 1475
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 12:17

I am trying to plot my coordinates using R. I have tried already to follow different post (R: Plot grouped coordinates on world map ; Plotting coordinates of multiple points

4条回答
  •  萌比男神i
    2020-12-07 13:00

    Here is a solution using only Rgooglemaps, as requested by the user.

    # get map (from askers OP, except changed map type = "Satallite" to type = "Satellite")
    library(RgoogleMaps)
    lat <- c(-38.31, -35.50) #define our map's ylim
    lon <- c(40.96,37.50) #define our map's xlim
    center = c(mean(lat), mean(lon))  #tell what point to center on
    zoom <- 2 #zoom: 1 = furthest out (entire globe), larger numbers = closer in
    terrmap <- GetMap(center=center, zoom=zoom, type= "satellite", destfile = "satellite.png")
    
    # plot points and save image
    lat <- c(-38.31, -57.59, -39.47)
    lon <- c(40.96, 76.51, 108.93)
    png('map.png')
    PlotOnStaticMap(terrmap, lat = lat, lon = lon, pch = 20, col = c('red', 'blue', 'green'))
    dev.off()
    

提交回复
热议问题