我需要在R中的ggplot2中制作的全局地图中添加比例尺,而easiest way似乎是通过ggsn包。
但是当我对地图进行观察时,比例尺看起来并不正确 - 例如,它在整个澳大利亚E-W的距离大约为4000公里,比非洲赤道的距离要小一些。 2000公里规模的酒吧在赤道看起来比非洲宽,几乎和澳大利亚一样宽。
感谢您的想法!
可重复的代码:
library(ggplot2)
library(ggsn)
library(dplyr)
GG.GlobalMap = map_data("world") %>%
filter(region != "Antarctica")
ggplot(GG.GlobalMap, aes(long, lat, group = group)) +
geom_path(color = "black") +
scalebar(data = GG.GlobalMap, dist = 1000, dd2km = TRUE, model = "WGS84",
st.size = 3, location = "bottomright") +
theme_void()
答案 0 :(得分:1)
在您使用的简单的长度投影中,距离随纬度而变形,随着它们越来越接近而逐渐拉伸。在极点处,单个点伸展到矩形地图的整个宽度。因此,不建议在此类地图上使用比例尺,因为它们的大小仅在特定纬度上是正确的,并且在地图上的其他任何位置都会产生误导。我们可以通过在不同纬度绘制一系列比例尺来看到这一点,以显示它们的大小变化:
ggplot() +
geom_path(data = map_data("world"), aes(long, lat, group = group), color = "grey80") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = -80, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = -60, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = -40, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = -20, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = 0, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = 20, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = 40, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = 60, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
scalebar(dist = 1000, dd2km = TRUE, model = "WGS84", y.min = 80, y.max = 90, x.min = -180, x.max = 180, st.size = 2, location = "bottomright") +
theme_void()
出于这个原因,通常建议在小规模的全球地图上使用刻度而不是比例尺。
ggplot() +
geom_path(data = map_data("world"), aes(long, lat, group = group), color = "black") +
scale_x_continuous(breaks = (-9:9)*20) +
scale_y_continuous(breaks = (-9:9)*10) +
theme_bw() +
theme(panel.grid.major = element_line(colour = 'grey50', size = 0.3, linetype = 3))
如果您真的想使用比例尺,则应首先将数据(使用spTransform
)重新投影到等面积投影,其距离最小或完全没有扭曲。