Map of data by country
조회 수: 30 (최근 30일)
이전 댓글 표시
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
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
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
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:
- https://www.naturalearthdata.com/downloads/
- https://www.mathworks.com/help/map/ref/geoshow.html
Hope this helps!
Best Regards,
Aryan Gupta
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Map Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!