To usa counties and state mape and shade with different color
16 views (last 30 days)
I am working on a project and basically, I'm trying to import a map of US with counties in deffernet states marked on it. my purpose is to add data about each county, specifically about the concentration of spread of Covid cases.US. Then, I want to give each county a certain shade of color based on the concentration.
Does Matlab have a feature which can detect the counties on a map? if so, can each element (county) store data and be assigned individual colors?
I am experienced in Matlab and have coded a lot of numerical analysis projects before. This is a side project, and I've never worked with image importing and detection in Matlab, which is why I'm asking.
Chunru on 29 Nov 2021
Edited: Chunru on 29 Nov 2021
states = shaperead( 'usastatehi.shp'); % MATALB comes with usa states map .shp file
You can download the county level map from:
% Extract the polygons in the .shp file
struct2poly = @(s) polyshape(s.X, s.Y);
p = arrayfun(struct2poly, states);
% to specify the color for each state
figure; hold on
plot(p(1), 'FaceColor', 'r');
plot(p(2), 'FaceColor', 'g');
plot(p(3), 'FaceColor', 'b'); % and so on