How can I change the color of a map given shapefile and values?

39 views (last 30 days)
Emanuele Massaro
Emanuele Massaro on 22 Jul 2015
Answered: Nitin Khola on 24 Jul 2015
Hello, I would like to generate a map from shapefiles given where for each provinces I have a specific value. Let say I have 52 provinces, so I have an array of 52 different values. What I am doing now is to generate a loop:
for i = 1:52
How can I generate "I" and have a colorbar that indicates the real values? Now I am able to generate something like this but it is not what I want.
All the best.

Answers (1)

Nitin Khola
Nitin Khola on 24 Jul 2015
As per my understanding, you wish to change the 'FaceColor' of polygons depicting provinces, as per some particular data values, which can be displayed using "mapshow" or "geoshow". Further, I understand that you are importing a shapefile containing the necessary information.
One of the possible methods to do this is by making a rule for the 'Polygon' geometry using " makesymbolspec " function.
A step by step procedure to do it is described in the following example:
The sections most relevant to you are:
Create an autumn colormap for the six New England states, and then use the flipud command to invert the matrix.
fall = flipud(autumn(numel(NEstates)));
Make a symbol specification structure, a symbolspec , that assigns an autumn color to each polygon according to the population density.
densityColors = makesymbolspec('Polygon', {'PopDens2000', ...
[0 maxdensity], 'FaceColor', fall});
This example creates an "autumn" colormap to display population density data. However, as stated in the example, you can experiment with other colormaps as well. You can also create a custom colormap.
For more information on using colorbars and colormaps in regard to representing geographic variables on maps, refer to the following documentation:

Community Treasure Hunt

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

Start Hunting!