how can I get a list of the countries used by the mapping toolbox as a cell array?
Show older comments
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)
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}
You might find these functions useful:
https://www.mathworks.com/help/textanalytics/ref/correctspelling.html with option "KnownWords"
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)
setdiff(categories(data),countryList)
data = mergecats(data,["France" "Franz"]);
data = mergecats(data,["USA" "Unites States"],"United States")
data = removecats(data,"Junk")
data = rmmissing(data)
Categories
Find more on Mapping Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!