Dealing with thematic maps, how to read a shapefile and giving him an additional data array

4 views (last 30 days)
Hello to everybody, i'm trying to learn how to build rapidly a thematic map of several parameters that i have to represent but, following the guidelines (<http://www.mathworks.it/it/help/map/thematic-maps-1.html>) i could not get totally the point. This is the matter: i have to represent with a thematic map the variation of the Production Price of the Wheat across the world in 2011. First of all i have loaded a shapefile of the world (that is TM_WORLD_BORDERS-0.3.shp). It has all the informations to create a map of the world and to recognize the boundaries of the nations.
world=shaperead('TM_WORLD_BORDERS-0.3.shp')
By reading the suggestions in the tutorial it has been easy to make a thematic map according to one of the parameters that is already inside the shapefile (the shp has already inside NAME AREA POP2005 REGION SUBREGION LON LAT) by using
maxdensity = max([world.POP2005]);
fall = flipud(autumn(numel(world)));
densityColors = makesymbolspec('Polygon', {'POP2005',[0 maxdensity], 'FaceColor', fall});
geoshow(world, 'DisplayType', 'polygon','SymbolSpec', densityColors)
title ({'density population of nations in 2005'})
but i did not understand how to arrange a thematic map according to a column array coming from outside the shapefile . for example, the production price that i have just downloaded from FAOSTAT website.
thanks a lot

Accepted Answer

Kelly Kearney
Kelly Kearney on 25 Aug 2014
If you're comfortable with the geoshow/symbolspec combo, the easiest way to do this would be to add your additional data as new fields to the structure:
pth = '~/Documents/Research/Data/TM_WORLD_BORDERS-0.3/'; % change as appropriate
world = shaperead(fullfile(pth, 'TM_WORLD_BORDERS-0.3.shp'), 'usegeocoords', true);
mystat = num2cell(1:246);
ss = makesymbolspec('Polygon', {'mystat', [1 246], 'facecolor', jet(64)});
[world.mystat] = deal(mystat{:});
geoshow(world, 'DisplayType', 'polygon','SymbolSpec', ss);
  6 Comments
Alessandro
Alessandro on 9 Sep 2014
Actually i would prefer to continue using the old way, at least to have all the graphs drawn in the same way! as you can see below, i've managed to define the colour boundaries according to the values but there is a scam: i think that, even if i'm setting the colour boundaries, the colorbar is doing on its own and it is not considering them but only the minimum and the maximum limits. This would be a problem because i would like to have lots of colours for the range value going from 0 to 1000 and one colour describing values from 1000 to MAX (outliers), instead colourbar divides the color range in an equal way.
pth = '/Users/macbook/.../TM_WORLD_BORDERS-0.3/';
mapworld = shaperead(fullfile(pth, 'TM_WORLD_BORDERS-0.3.shp'), 'usegeocoords', true);
mapdatas = num2cell(Cln);
MAPmaxdensity = max([Cln])
mapss = makesymbolspec('Polygon',...
{'mapdatas', [0 150], 'facecolor', [0 0 255]},
{'mapdatas', [150 250], 'facecolor', [153 203 255]},
{'mapdatas', [250 350], 'facecolor', [153 255 204]},
{'mapdatas', [350 550], 'facecolor', [0 255 0]},...
{'mapdatas', [550 1000], 'facecolor', [255 0 0]},...
{'mapdatas', [1000 MAPmaxdensity], 'facecolor', [255 36 0]},...
{'Default', 'facecolor', 'w'});
[mapworld.mapdatas] = deal(mapdatas{:});
caxis([0 MAPmaxdensity])
colormap(jet(8))
colorbar
geoshow(mapworld, 'DisplayType', 'polygon','SymbolSpec', mapss)
title ({''})
If i could solve the problem of colorbar would be easy also to represent logarithmic values, thanks for the help.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!