为什么用 R 中的 ggmap ggsn 创建的比例尺显示不准确的距离?

问题描述

我正在尝试使用 ggmapggsn 的开发者版本创建带有比例尺的简单地图。地图似乎加载良好,但比例尺测量值似乎不正确。在美国,从海岸到海岸的距离不应超过 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')

Example map

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)