How can I change the color of a country using a shapefile?

4 views (last 30 days)
Hello all,
I have downloaded a shapefile including all countries from the Natural Earth website: http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_0_countries.zip
I first read the shapefile:
%%Load country borders shapefile
country_border_file = 'shapefiles\ne_50m_admin_0_countries\ne_50m_admin_0_countries.shp';
country_borders = shaperead(country_border_file,'UseGeoCoords',true);
and then plot it using the geoshow function:
ax = axesm('mercator');
geoshow(ax, [country_borders.Lat], [country_borders.Lon], 'Color', 'k');
Everything works fine for this. Now, I would like to colour Germany and UK land areas a specific colour to improve map visibility. I run the following code:
ax = axesm('mercator');
symspec = makesymbolspec('Polygon', ...
{'name', 'Germany', 'FaceColor', [0.15 0.5 0.15]}, ...
{'name', 'United Kingdom', 'FaceColor', [0.15 0.5 0.15]});
geoshow(ax,country_borders,'SymbolSpec', symspec)
And I get the following error messages:
*??? Error using ==> line Invalid property found. Object Name : line Property Name : 'SymbolSpec'.
Error in ==> mapline at 24 h = line(xdata(:), ydata(:), 'Color', [0 0 1], varargin{:});
Error in ==> geovec at 22 h = fcn(x, y, varargin{:});
Error in ==> geovecshow at 66 h = geovec(mstruct, lat, lon, ...
Error in ==> geoshow at 273 h = showFcn(varargin{:});*
Generally, I am not able to do anything beyond plot the lines. Facecolor and other arguments do not work either giving similar error messages.
My question is: Is there a way around this problem (and if not) is there a freely-available shapefile (I have tested many other with similar problems) that has been tested to work well with MATLAB (i.e. country-specific colour painting works)?
Thank you very much in advance, Ioannis

Answers (0)

Community Treasure Hunt

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

Start Hunting!