Emma Tebbs
Emma Tebbs

Reputation: 1467

Plot individual countries with matlab mapping toolbox

I would like to draw a map of specific countries in matlab using the mapping toolbox. Specifically, I would like to draw a map of Austria and Switzerland only.

I have tried the following:

ax = worldmap({'Austria','Switzerland'});
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])
lakes = shaperead('worldlakes', 'UseGeoCoords', true);
geoshow(lakes, 'FaceColor', 'blue')
rivers = shaperead('worldrivers', 'UseGeoCoords', true);
geoshow(rivers, 'Color', 'blue')

which produces

enter image description here

However, I would like something that looks more like this, which is the countries specified, without the other European countries included in the figure. Is this possible in matlab?

Upvotes: 0

Views: 3280

Answers (1)

nkjt
nkjt

Reputation: 7817

Possible, yes, but you would need another shapefile, containing information about the individual countries.

worldmap only sets the boundaries of the map. The other information you plot comes out of the shapefile you load and doesn't check what countries you set in worldmap - and even if it did, couldn't do anything with the information, because if you check land you'll see the individual countries in Europe aren't listed. You could either get specific shapefiles just for those two countries, or get a shapefile containing something like data for all Europe and just pull out details of those two countries from it.

A simple example for the US using builtin data: this loads a set of data about all states but extracts and plots only Texas:

ax = worldmap({'USA'});
land = shaperead('usastatehi', 'UseGeoCoords', true);
n = strcmp({land.Name},'Texas');
geoshow(ax, land(n))

Upvotes: 1

Related Questions