如何解决为什么用 R 中的 ggmap ggsn 创建的比例尺显示不准确的距离?
我正在尝试使用 ggmap
和 ggsn
的开发者版本创建带有比例尺的简单地图。地图似乎加载良好,但比例尺测量值似乎不正确。在美国,从海岸到海岸的距离不应超过 4,000 公里。以下是我当前的代码。
##installing packages.. not all are needed
library(tidyverse)
library(ggplot2)
library(sf)
library(ggspatial)
library(devtools)
library(ggmap)
library(maptools)
library(maps)
library(magick)
library(VTrack)
library(cowplot)
library(gridExtra)
## register a google api key
ggmap::register_google(key = "")
##creating the base map
inset <- get_googlemap(center = c(lon = -90,lat = 50),zoom = 3,maptype = "satellite",color = 'bw')
##below just makes the map a little lighter
insetx <- inset
inset_attributes <- attributes(insetx)
inset_transparent <- matrix(adjustcolor(insetx,alpha.f = 0.9),nrow = nrow(inset))
attributes(inset_transparent) <- inset_attributes
##installing dev version of ggsn
devtools::install_github('oswaldosantos/ggsn')
##combining the map with the scale bar. Note that scale bar appears to be off.
ggmap(inset_transparent)+
ggsn::scalebar(x.min = -180,x.max = -100,y.min = 10,y.max = 85,dist = 2000,transform = TRUE,dist_unit = 'km',model = 'WGS84',box.fill = c('black','black'),st.color = 'white',box.color = 'white')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。