R中的制图不会扭曲国家/地区

时间:2019-02-22 16:29:07

标签: r cartogram

我正在使用R中的cartogram程序包来绘制生活语言的世界地图。国家/地区地图来自Natural Earth,语言计数来自Ethnologue

w <- readOGR('.','ne_110m_admin_0_map_units')
L <- read.csv('languages.csv',sep='\t')
w$rank <- 1:nrow(w)
wl <- merge(w@data,L,by.x='ISO_A3',by.y='iso3',all.x=T)
wl <- wl[order(wl$rank),]
wl[is.na(wl$Live),'Live'] <- 1
w@data <- wl
w2 <- cartogram_cont(w,'Live',prepare='none')
plot(w2)

Living languages cartogram

我使用的数据在俄罗斯有111种在用语言,在中国则有299种,几乎是三倍。但是,创建的地图仍然显示俄罗斯大于中国。

以下是每个国家/地区的数据:

> w@data[order(w$NAME),c('NAME','Live')]
                        NAME Live
13               Afghanistan   41
15                   Albania    8
57                   Algeria   18
14                    Angola   45
19                Antarctica    1
17                 Argentina   24
18                   Armenia    8
21                 Australia  206
22                   Austria   14
23                Azerbaijan   18
30                   Bahamas    3
28                Bangladesh   41
32                   Belarus    4
25                   Belgium   11
33                    Belize    8
26                     Benin   55
37                    Bhutan   23
34                   Bolivia   43
31          Bosnia and Herz.    4
38                  Botswana   31
12              Bougainville    1
35                    Brazil  218
36                    Brunei   15
29                  Bulgaria   12
27              Burkina Faso   71
24                   Burundi    3
99                  Cambodia   27
45                  Cameroon  277
40                    Canada   96
39      Central African Rep.   72
161                     Chad  131
42                     Chile   11
43                     China  299
48                  Colombia   84
47                     Congo   62
49                Costa Rica   11
44             Côte d'Ivoire   85
82                   Croatia   15
50                      Cuba    3
51                    Cyprus    4
52                   Czechia   10
46           Dem. Rep. Congo  211
55                   Denmark    5
54                  Djibouti    5
56            Dominican Rep.    4
58                   Ecuador   24
59                     Egypt   15
152              El Salvador    5
2                    England    1
75                Eq. Guinea   14
60                   Eritrea   15
63                   Estonia    7
159                 eSwatini    5
64                  Ethiopia   88
67              Falkland Is.    1
66                      Fiji   10
65                   Finland   13
20    Fr. S. Antarctic Lands    1
68                    France   22
79             French Guiana   13
69                     Gabon   43
73                    Gambia   11
70                   Georgia   20
53                   Germany   25
71                     Ghana   81
76                    Greece   18
77                 Greenland    3
78                 Guatemala   27
72                    Guinea   36
74             Guinea-Bissau   23
80                    Guyana   16
83                     Haiti    4
81                  Honduras   10
84                   Hungary   17
90                   Iceland    2
86                     India  448
85                 Indonesia  707
88                      Iran   78
89                      Iraq   23
87                   Ireland    5
91                    Israel   34
92                     Italy   34
93                   Jamaica    4
95                     Japan   15
94                    Jordan   11
96                Kazakhstan   14
97                     Kenya   67
5                     Kosovo    1
101                   Kuwait    3
98                Kyrgyzstan    6
102                     Laos   83
110                   Latvia    7
103                  Lebanon    7
107                  Lesotho    5
104                  Liberia   31
105                    Libya    9
108                Lithuania   10
109               Luxembourg    4
115                Macedonia   10
113               Madagascar   14
122                   Malawi   17
123                 Malaysia  134
116                     Mali   68
121               Mauritania    7
114                   Mexico  287
112                  Moldova   10
119                 Mongolia   12
118               Montenegro    6
111                  Morocco   14
120               Mozambique   43
117                  Myanmar  118
4                  N. Cyprus    1
1                 N. Ireland    1
124                  Namibia   27
130                    Nepal  121
129              Netherlands   15
125            New Caledonia   38
131              New Zealand    4
128                Nicaragua   11
126                    Niger   23
127                  Nigeria  519
139              North Korea    1
6                     Norway    1
132                     Oman   17
133                 Pakistan   74
134                   Panama   15
7           Papua New Guinea    1
141                 Paraguay   23
135                     Peru   93
136              Philippines  183
137                   Poland   21
140                 Portugal    9
138              Puerto Rico    4
142                    Qatar    3
143                  Romania   23
144                   Russia  111
145                   Rwanda    3
154                 S. Sudan   69
146             Saudi Arabia    7
8                   Scotland    1
148                  Senegal   38
3                     Serbia    1
151             Sierra Leone   24
156                 Slovakia   11
157                 Slovenia    7
150              Solomon Is.   73
153                  Somalia   13
9                 Somaliland    1
181             South Africa   30
100              South Korea    3
62                     Spain   16
106                Sri Lanka    7
147                    Sudan   75
155                 Suriname   21
149             Svalbard Is.    1
158                   Sweden   15
41               Switzerland   12
160                    Syria   18
170                   Taiwan   22
164               Tajikistan   13
171                 Tanzania  125
163                 Thailand   71
166              Timor-Leste   20
162                     Togo   44
167      Trinidad and Tobago    7
168                  Tunisia    6
169                   Turkey   39
165             Turkmenistan    6
172                   Uganda   43
173                  Ukraine   22
16      United Arab Emirates   10
175 United States of America  219
174                  Uruguay    5
176               Uzbekistan   11
179                  Vanuatu  111
177                Venezuela   42
178                  Vietnam  109
61                 W. Sahara    3
10                     Wales    1
11                 West Bank    1
180                    Yemen   11
182                   Zambia   46
183                 Zimbabwe   22

我在做什么错了?

编辑

按照FuzzyLeapfrog的回答,我删除了南极洲并将地图转换为罗宾逊投影。

w <- w[-grep('Antarctica',w$NAME),]
w1 <- spTransform(w,CRS('+proj=robin'))
w2 <- cartogram_cont(w1,'Live')
tom <- 1 - w$Live/max(w$Live) # tonality
plot(w,col=rgb(tom,tom,tom))
plot(w1,col=rgb(tom,tom,tom))
plot(w2,col=rgb(tom,tom,tom))

以下是三个贴图:墨卡托投影,罗宾逊投影和变形后。灰色调与活动语言的数量成正比(越深,数量越大)。

Mercator projection

Robinson projection

Robinson projection, deformed

您难道不认为俄罗斯仍然比中国大吗?应该是中国的1/3吗?

EDIT2

上面的Natural Earth地图是一个轻量级的shapefile(.shp只有182 kB)。使用更详细的地图(具有6.5 MB的.shp),我得到了以下地图(Robinson投影和Robinson变形)。俄罗斯仍然太大了!我想知道该国的原始规模是否会影响最终形状(我以为没有影响,但现在我以为会影响)。可能有一个选择,使原始大小不会影响最终结果?

detailed Robinson projection

detailed Robinson deformed

EDIT3

我尝试了两个相等的面积投影,分别为Mollweide和Lambert Cylindrical。以下是兰伯特(现在为红色)的结果,首先是投影图,然后是投影+变形图。红色越多,面积应该越大。事实并非如此(只需将巴布亚新几内亚与澳大利亚进行比较即可。)

Lambert Equal Area Projection

Lambert Equal Area Projection + cartogram deformation

我想知道cartogram_cont包中的cartogram函数是否确实执行了我认为应该做的事情?帮助页面说它遵循“橡胶板变形算法(Dougenik等,1985)”。

1 个答案:

答案 0 :(得分:2)

不仅俄罗斯和中国的规模不正确,南极洲也是如此。看起来您正在使用墨卡托投影。我建议转换世界地图数据,并排除南极洲,例如就像this blog post中建议的那样:

library(dplyr) # data manipulation
[...]
world_map = ne_countries(returnclass = "sf")
world_map = world_map %>% 
    select(sovereignt) %>% 
    filter(sovereignt != "Antarctica") %>% 
    st_transform(world_map, crs = "+proj=robin")
[...]

使争吵的大小变形的是a)投影和b)重量(在您的情况下为多种语言)增加了。 a)的影响变小,例如通过缩小查看范围或使用等面积投影(例如Mollweide)来实现。