ggsn全球地图比例尺看起来不对

ggsn全球地图比例尺看起来不对

本文介绍了ggsn全球地图比例尺看起来不对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在R中的ggplot2中创建的全局地图中添加比例尺,并且似乎是通过ggsn软件包进行的.

I need to add a scale bar to a global map made in ggplot2 in R, and the easiest way seemed to be via the ggsn package.

但是当我盯着地图看时,比例尺看起来不正确-例如,横跨澳大利亚E-W的距离约为4000公里,比整个非洲赤道的距离要短一些.在赤道处,2000公里的比例尺看起来比非洲宽,几乎和澳大利亚一样宽.

But the scale bar doesn't look right when I eyeball the map - e.g., it's ~4000km across Australia E-W, and a bit less than that across Africa at the equator. The 2000km scale bar looks wider than Africa at the equator and almost as wide as Australia.

感谢您的想法!

可复制的代码:

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()

推荐答案

在您使用的简单的经纬投影中,距离随着纬度而变形,随着距离的增加,距离逐渐变长.在极点处,单个点被拉伸到矩形地图的整个宽度.因此,不建议在此类地图上使用比例尺,因为比例尺的大小仅在特定纬度下才是正确的,并且会误导地图上的其他位置.我们可以通过在各种纬度上绘制一系列比例尺以显示它们的大小变化来观察实际情况:

In the simple lat-long projection you are using, distances are distorted with latitude, becoming progressively stretched as they get closer to the poles. At the poles, a single point is stretched out to the full width of the rectangular map. As a result, it is not recommended to use scale bars on such maps, because their size would only be correct at a specific latitude, and is misleading everywhere else on the map. We can see this in action by plotting a series of scale bars at various latitudes, to show how they vary in size:

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()

因此,通常建议在小比例尺的全球地图上使用刻度线而不是比例尺.

For this reason, it is usually recommended to use a graticule rather than scale bars on small scale global maps.

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)到等面积投影,对于该投影而言,距离的失真很小或根本没有失真.

If you really want to use a scale bar, you should first reproject your data (using spTransform) to an equal-area projection, for which distances are distorted only minimally or not at all.

这篇关于ggsn全球地图比例尺看起来不对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!