How do I create a map of the US and express the color of each state based on it's air-traffic density?

19 views (last 30 days)
I have a map of the US created using GEOSHOW and I want to express the airport passenger density in each state in a colormap type graph.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
A thematic map displays quantified facts (a "theme"), such as statistics for a region or sets of regions. Examples include the locations of traffic accidents in a city, or election results by state. These maps can be useful to represent maps based on userdefined data fields.
An example on how to do this is presented below:
Step 1. The SHAPEREAD function reads the 'usastatelo' map and returns a sructure with the following fields 'Geometry', 'BoundingBox', ' Lon', ' Lat', ' Name', 'LabelLat' and ' LabelLon'. However these fields are predefined fields and additional fields can be defined. This can be done as follows
states = shaperead('usastatelo');
Step 2. Next step is to add a userdefined field "AirTraffic" to the structure "states" and its value is set to variable 'k' (this value can also be based on the state name by verifying state(k).Name attribute). The loop is performed over all the states starting from 1 to numel(states).
for k = 1:numel(states)
states(k).AirTraffic = k;
end
Step 3. Next step is to define the 'SymbolSpec' attribute (in this case it is named as surfaceColors) which is then used by the geoshow to specify the color density in the map. This is done as follows
surfaceColors = makesymbolspec('Polygon', {'AirTraffic', [min([states.AirTraffic]) max([states.AirTraffic])], 'FaceColor', autumn(numel(states)) });
The colormap is based on the minimum and maximum values of the states.AirTraffic attribute and the colormap style is autumn.
Step 4. The final step is to use the geoshow to plot the map with the 'SymbolSpec' attribute defined by the surfaceColors defined in the above step
geoshow(states,'DisplayType', 'polygon', 'SymbolSpec', surfaceColors);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!