placenames
Description
Examples
Get Placenames in Installed List
By default, the geocode
function gets a shape object for a specified placename by searching an installed list of placenames. Get the installed list of placenames.
names = placenames;
When you do not specify an administration level, the list contains the names of world regions, US states, and world cities. View the first 10 placenames in the list.
names(1:10)
ans = 10×1 string
"Aaland Islands"
"Abidjan"
"Abu Dhabi"
"Accra"
"Adana"
"Addis Ababa"
"Adelaide"
"Aden"
"Afghanistan"
"Africa"
Create a geospatial table that contains a point shape for the city of Adelaide by using the geocode
function. Display the point shape on a map.
geocodedGT = geocode("Adelaide"); geoplot(geocodedGT,"*") geolimits([-40 -30],[131 146])
Get Placenames by Administration Level
The installed list of placenames contains the names of world regions, US states, and world cities. Get a list that contains only the names of world regions.
names = placenames("region");
View the first 10 placenames in the list.
names(1:10)
ans = 10×1 string
"Aaland Islands"
"Afghanistan"
"Africa"
"Africa and Eurasia"
"Agalega Island"
"Albania"
"Alderney"
"Algeria"
"American Samoa"
"Andorra"
Create a geospatial table that contains an area of interest (AOI) for the Aaland Islands by using the geocode
function. Display the boundary of the AOI on a map.
geocodedGT = geocode("Aaland Islands"); geoplot(geocodedGT,FaceColor="none")
Search for Placenames in Installed List
The geocode
function issues an error when you specify a placename that has multiple matches. You can find an exact match for a placename by searching the installed list.
Get a list that contains only the names of US states. Then, determine which placenames contain new
by using the contains
function. The contains
function returns a logical value for each placename, where values of 1
correspond to placenames that contain new
.
names = placenames("state"); idxNew = contains(names,"new",IgnoreCase=true);
Extract the placenames that contain new
.
containsNew = names(idxNew)
containsNew = 4×1 string
"New Hampshire"
"New Jersey"
"New Mexico"
"New York"
Create a geospatial table that contains an AOI for New Jersey by using the geocode
function. Extract the AOI from the table. Then, create a map using the latitude and longitude limits of the AOI. Note that, to maintain the aspect ratio of the map, the geolimits
function typically uses wider limits than the limits you specify.
geocodedGT = geocode("New Jersey");
aoi = geocodedGT.Shape;
[latlim,lonlim] = bounds(aoi);
geolimits(latlim,lonlim)
Input Arguments
adminlevel
— Administration level
"all"
(default) | "region"
| "state"
| "city"
Administration level, specified as one of these options:
"region"
— World regions"state"
— US states and the District of Columbia"city"
— World cities"all"
— All administration levels
Output Arguments
names
— Placenames
M-by-1 vector of strings
Placenames, returned as an M-by-1 vector of strings.
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)