Map of data by country

27 visualizaciones (últimos 30 días)
Brendan Clark
Brendan Clark el 13 de Sept. de 2021
Respondida: ag el 13 de Oct. de 2023
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 comentarios
Star Strider
Star Strider el 13 de Sept. de 2021
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 el 14 de Sept. de 2021
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

Iniciar sesión para comentar.

Respuestas (1)

ag
ag el 13 de Oct. de 2023
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

Community Treasure Hunt

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

Start Hunting!

Translated by