Map of data by country

42 ビュー (過去 30 日間)
Brendan Clark
Brendan Clark 2021 年 9 月 13 日
回答済み: ag 2023 年 10 月 13 日
I have a table with two columns. One is the name of all countries on Earth, the other is a corresponding numeric value. I would like to make a world map with each countries individual face color representing that value. I will attach an example of what I mean. Is there a way to do this?
  3 件のコメント
Star Strider
Star Strider 2021 年 9 月 13 日
I don’t have the Mapping Toolbox, however I experimented with it in the online Run application, that does. There may be a shape file that defines the country borders as polygons, however if it exists, its existence doesn’t appear to be documented.
.
Dave B
Dave B 2021 年 9 月 14 日
It might be worth checking out the borders submission on file exchange, which can do this sort of thing though it might be a little slow to show all countries: https://www.mathworks.com/matlabcentral/fileexchange/50390-borders

サインインしてコメントする。

回答 (1 件)

ag
ag 2023 年 10 月 13 日
Hi Brendan,
I understand that you need to make a world map, with individual face colours for each country.
You can explore the “Natural Earth Data” website to get the required data, and then refer the below code, to get a broad idea on how to go ahead with your task,
world = shaperead('ne_110m_land.shp')
world.BoundingBox
figure;
ax = axes;
col = string({'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'white', 'none'})
for i = 1:numel(world)
country = world(i);
value = randperm(80,1);
% Set the face color based on the value
v = mod(value(1),8)+1;
disp(col(v))
faceColor = col(v);
% Plot the country with the specified face color
geoshow(ax, country, 'FaceColor', faceColor);
hold on;
end
colorbar;
Please refer to the following resources for more details:
Hope this helps!
Best Regards,
Aryan Gupta

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by