how can I get a list of the countries used by the mapping toolbox as a cell array?

10 views (last 30 days)
I need to map countries in a dataset to countries on a map, but there are discrepencies in my data. mapping toolbox refers to 'USA' but my data uses 'United States' and corrupted data such as 'Unites States'. I wish to scrub my data for issues by comparing 60,000 entries against a definitive list of mappable countries. I know I can see a list of countries by typing worldmap() but how can I get this list into a cell array or table?

Answers (2)

Stephen23
Stephen23 on 22 Nov 2023
Edited: Stephen23 on 22 Nov 2023
The regions used by WORLDMAP are (note that this is in a private directory, is subject to change, use at own risk):
F = fullfile(toolboxdir("map"),"mapdisp","private","regions.mat");
S = load(F,'worldRegions');
C = {S.worldRegions.name}
C = 1×293 cell array
Columns 1 through 12 {'World'} {'Africa'} {'Antarctica'} {'Asia'} {'Eurasia'} {'Europe'} {'North America'} {'South America'} {'North Pole'} {'South Pole'} {'Pacific'} {'Afghanistan'} Columns 13 through 22 {'Agalega Island'} {'Albania'} {'Alderney'} {'Algeria'} {'American Samoa'} {'Andorra'} {'Angola'} {'Anguilla'} {'Antigua and Barb…'} {'Antipodes Islands'} Columns 23 through 33 {'Argentina'} {'Armenia'} {'Aruba'} {'Auckland Islands'} {'Australia'} {'Austria'} {'Azerbaijan'} {'Azores'} {'Bahamas, The'} {'Bahrain'} {'Baker Island'} Columns 34 through 44 {'Bangladesh'} {'Barbados'} {'Bassas da India'} {'Belarus'} {'Belgium'} {'Belize'} {'Benin'} {'Bermuda'} {'Bhutan'} {'Bjornoya'} {'Bolivia'} Columns 45 through 54 {'Bosnia and Herze…'} {'Botswana'} {'Bounty Islands'} {'Bouvet Island'} {'Brazil'} {'British Indian O…'} {'Broughton Islands'} {'Brunei'} {'Bulgaria'} {'Burkina Faso'} Columns 55 through 64 {'Burma'} {'Burundi'} {'Cambodia'} {'Cameroon'} {'Campbell Islands'} {'Canada'} {'Canary Islands'} {'Cape Verde'} {'Cargados'} {'Cayman Islands'} Columns 65 through 74 {'Central African …'} {'Chad'} {'Chatham Islands'} {'Chile'} {'China'} {'Christmas Island'} {'Clipperton Island'} {'Cocos'} {'Colombia'} {'Comoros'} Columns 75 through 84 {'Congo, Democrati…'} {'Congo, Republic …'} {'Cook Islands'} {'Costa Rica'} {'Croatia'} {'Cuba'} {'Cyprus'} {'Czech Republic'} {'Denmark'} {'Djibouti'} Columns 85 through 94 {'Dominican Republ…'} {'East Timor'} {'Easter Island'} {'Ecuador'} {'Egypt'} {'El Salvador'} {'Equatorial Guinea'} {'Eritrea'} {'Estonia'} {'Ethiopia'} Columns 95 through 104 {'Europa Island'} {'Falkland Islands…'} {'Faroc Islands'} {'Faroe Islands'} {'Fiji'} {'Finland'} {'France'} {'French Antilles'} {'French Guyana'} {'French Polynesia'} Columns 105 through 114 {'French Southern …'} {'Gabon'} {'Galapagos Islands'} {'Gambia, The'} {'Georgia'} {'Germany'} {'Ghana'} {'Gibraltar'} {'Glorioso Islands'} {'Gough Island'} Columns 115 through 125 {'Greece'} {'Greenland'} {'Grenada'} {'Guadeloupe'} {'Guam'} {'Guatemala'} {'Guernsey'} {'Guinea, Republic…'} {'Guinea-Bissau'} {'Guyana'} {'Haiti'} Columns 126 through 136 {'Heard Island and…'} {'Honduras'} {'Howland Island'} {'Hungary'} {'Iceland'} {'India'} {'Indonesia'} {'Iran'} {'Iraq'} {'Ireland'} {'Isla Sala y Gomez'} Columns 137 through 146 {'Isla San Ambrosio'} {'Isla San Felix'} {'Isla de Annobon'} {'Isla del Coco'} {'Israel'} {'Italy'} {'Ivory Coast'} {'Jamaica'} {'Jan Mayen'} {'Japan'} Columns 147 through 156 {'Jarvis Island'} {'Jersey'} {'Johnson Atoll'} {'Jordan'} {'Juan de Nova Isl…'} {'Kazakhstan'} {'Kenya'} {'Kermadec Islands'} {'Kiribati'} {'Korea, Democrati…'} Columns 157 through 168 {'Korea, Republic …'} {'Kuwait'} {'Kyrgyzstan'} {'Laos'} {'Latvia'} {'Lebanon'} {'Lesotho'} {'Liberia'} {'Libya'} {'Liechtenstein'} {'Lithuania'} {'Luxembourg'} Columns 169 through 178 {'Macedonia, The F…'} {'Macquarie Island'} {'Madagascar'} {'Madeira Islands'} {'Malawi'} {'Malaysia'} {'Maldives'} {'Mali'} {'Malta'} {'Man, Isle of'} Columns 179 through 189 {'Marshall Islands'} {'Martinique'} {'Mauritania'} {'Mauritius'} {'Mayotte'} {'Mexico'} {'Micronesia, Fede…'} {'Midway Islands'} {'Moldova'} {'Monaco'} {'Mongolia'} Columns 190 through 199 {'Montenegro'} {'Montserrat'} {'Morocco'} {'Mozambique'} {'Namibia'} {'Nauru'} {'Navassa Island'} {'Nepal'} {'Netherlands Anti…'} {'Netherlands, Kin…'} Columns 200 through 210 {'New Caledonia'} {'New Zealand'} {'Nicaragua'} {'Niger, Republic …'} {'Nigeria'} {'Niue'} {'Norfolk Island'} {'Northern Mariana…'} {'Norway'} {'Oman'} {'Pakistan'} Columns 211 through 220 {'Palau, Republic …'} {'Palmyra Atoll'} {'Panama'} {'Papua New Guinea'} {'Paracel Islands'} {'Paraguay'} {'Peru'} {'Philippines'} {'Pitcairn Islands'} {'Poland'} Columns 221 through 231 {'Portugal'} {'Pratas Island'} {'Prince Edward Is…'} {'Puerto Rico'} {'Qatar'} {'Reunion'} {'Rodrigues'} {'Romania'} {'Russia'} {'Rwanda'} {'Saint Helena'} Columns 232 through 240 {'Saint Kitts and …'} {'Saint Lucia'} {'Saint Pierre and…'} {'Saint Vincent an…'} {'San Marino'} {'Sao Tome and Pri…'} {'Saudi Arabia'} {'Senegal'} {'Serbia'} Columns 241 through 250 {'Seychelles'} {'Sierra Leone'} {'Singapore'} {'Slovakia'} {'Slovenia'} {'Solomon Islands'} {'Somalia'} {'Sombrero'} {'South Africa'} {'South Georgia an…'} Columns 251 through 262 {'Spain'} {'Spratly Islands'} {'Sri Lanka'} {'Sudan'} {'Suriname'} {'Svalbard'} {'Swaziland'} {'Sweden'} {'Switzerland'} {'Syria'} {'Tajikistan'} {'Tanzania'} Columns 263 through 272 {'Tasmania'} {'Thailand'} {'Togo'} {'Tonga'} {'Trinidad and Tob…'} {'Tristan da Cunha…'} {'Tromelin Island'} {'Tunisia'} {'Turkey'} {'Turkmenistan'} Columns 273 through 282 {'Turks and Caicas…'} {'Tuvalu'} {'Uganda'} {'Ukraine'} {'United Arab Emir…'} {'United Kingdom'} {'United States of…'} {'Uruguay'} {'Uzbekistan'} {'Vanuatu'} Columns 283 through 292 {'Venezuela'} {'Vietnam'} {'Virgin Islands, …'} {'Virgin Islands, …'} {'Wake Island'} {'Wallis and Futuna'} {'Western Sahara'} {'Western Samoa'} {'Yemen'} {'Zambia'} Column 293 {'Zimbabwe'}
You might find these functions useful:

Peter Perkins
Peter Perkins on 27 Nov 2023
Stephen seems to have answered your question, but also, you will find categorical useful for cleaning your data:
countryList = ["France" "United States"];
data = ["France" "Franz" "USA" "Unites States" "Junk"];
data = categorical(data)
data = 1×5 categorical array
France Franz USA Unites States Junk
setdiff(categories(data),countryList)
ans = 4×1 string array
"Franz" "Junk" "USA" "Unites States"
data = mergecats(data,["France" "Franz"]);
data = mergecats(data,["USA" "Unites States"],"United States")
data = 1×5 categorical array
France France United States United States Junk
data = removecats(data,"Junk")
data = 1×5 categorical array
France France United States United States <undefined>
data = rmmissing(data)
data = 1×4 categorical array
France France United States United States

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!