Main Content

placenames

Installed list of placenames for geocode function

Since R2024b

Description

names = placenames gets the installed list of placenames used by the geocode function.

example

names = placenames(adminlevel) gets the list of placenames for the specified administrative level.

example

Examples

collapse all

Get the installed list of placenames used by the geocode function.

names = placenames;

When you do not specify an administrative 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"

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")

If the geocode function finds multiple matches while searching the installed list of placenames, the function issues an error. 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 startsWith function. The startsWith function returns a logical value for each placename, where values of 1 correspond to placenames that start with new.

names = placenames("state");
idxNew = startsWith(names,"new",IgnoreCase=true);

Extract the placenames that contain new.

startsWithNew = names(idxNew)
startsWithNew = 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

collapse all

Administrative level, specified as one of these options:

  • "region" — World regions

  • "state" — US states and the District of Columbia

  • "city" — World cities

  • "all" — All administrative levels

Output Arguments

collapse all

Placenames, returned as an M-by-1 vector of strings.

Version History

Introduced in R2024b