问题
I'm using the cartogram
package in R to make a world map of living languages. The country map is from Natural Earth, and the language count from the 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)
The data I'm using has 111 living languages in Russia and 299 in China, almost the triple. However, the cartogram created still displays Russia larger than China.
Here is the data from each country:
> 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
What am I doing wrong?
EDIT
Following FuzzyLeapfrog's answer, I removed Antarctica and transformed the map to Robinson projection.
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))
Following are the three maps: in Mercator projection, in Robinson projection, and after the deformation. The gray tone is proportional to the number of living languages (the darker, the greater the number).
Don't you think that still Russia is bigger than China, when it should be about 1/3 of it?
EDIT2
The Natural Earth map above is a lightweight shapefile (the .shp has only 182 kB). Using a more detailed map (.shp with 6.5 MB), I've got the following maps (Robinson projection and Robinson deformed). Russia's still too big! I wonder if the country's original size influences the final shape (I thought it didn't, but now I'm thinking it does). There might be an option so that the original size doesn't affect the final result?
EDIT3
I tried two equal area projections, Mollweide and Lambert Cylindrical. Below are the results for Lambert's, now in red, first the projected map, then the projected+deformed map. The more red, the greater the area should be. But it's not the case (just compare Papua New Guinea with Australia).
I wonder if cartogram_cont
function from cartogram
package really does what I think it should be doing; the help page says it follows the "rubber sheet distortion algorithm (Dougenik et al. 1985)".
回答1:
Not only russia and china are not sized properly but Antarctica, too. Looks like you are using a Mercator projection. I'd suggest to transorm the world map data and exclude Antarctica, e.g. like suggested in 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")
[...]
What deforms the size of the contries is a) the projection and b) the weight (in your case the amout of languages) you add. The impact of a) becomes smaller, e.g. by narrowing down the region you look at or by using an equal-area projection, like Mollweide.
来源:https://stackoverflow.com/questions/54831322/cartogram-in-r-not-distorting-countries-as-expected