Fixing maps library data for Pacific centred (0°-360° longitude) display

后端 未结 3 1907
小蘑菇
小蘑菇 2020-11-30 06:06

I\'m plotting some points on a map of the world using the R maps package, something like:

\"Map

3条回答
  •  伪装坚强ぢ
    2020-11-30 06:25

    install the latest version of maps (3.2.0).

    do this:

    d$lon2 <- ifelse(d$lon < -25, d$lon + 360, d$lon) # where d is your df
    mapWorld <- map_data('world', wrap=c(-25,335), ylim=c(-55,75))
    
    ggplot() +
    geom_polygon(data = mapWorld, aes(x=long, y = lat, group = group)) +
    geom_point(data = d, aes(x = lon2, y = lat))
    

提交回复
热议问题