Map of data by country
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Star Strider
am 13 Sep. 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
am 14 Sep. 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
Antworten (1)
ag
am 13 Okt. 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:
- https://www.naturalearthdata.com/downloads/
- https://www.mathworks.com/help/map/ref/geoshow.html
Hope this helps!
Best Regards,
Aryan Gupta
0 Kommentare
Siehe auch
Kategorien
Mehr zu Map Display finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!