extractm

Coordinate data from line or patch display structure

extractm will be removed in a future release. The use of display structures is not recommended. Use geoshape vectors instead.

Syntax

[lat,lon] = extractm(display_struct,object_str)
[lat,lon] = extractm(display_struct,object_strings)
[lat,lon] = extractm(display_struct,object_strings,searchmethod)
[lat,lon] = extractm(display_struct)
[lat,lon,indx] = extractm(...)
mat = extractm(...)

Description

[lat,lon] = extractm(display_struct,object_str) extracts latitude and longitude coordinates from those elements of display_struct having 'tag' fields that begin with the string scalar or character vector specified by object_str. display_struct is a Mapping Toolbox™ display structure in which the 'type' field has a value of either 'line' or 'patch'. The output lat and lon vectors include NaNs to separate the individual map features. The comparison of 'tag' values is not case-sensitive.

[lat,lon] = extractm(display_struct,object_strings) selects features with 'tag' fields matching any of several different string scalar or character vectors. object_strings is a string scalar, character vector, cell array of character vectors, or character array. extractm strips trailing spaces from features listed in character arrays before matching.

[lat,lon] = extractm(display_struct,object_strings,searchmethod) specifies the method used to match the values of the 'tag' field in display_struct. searchmethod can be one of these values:

'strmatch'Search for matches at the beginning of the tag
'findstr'Search within the tag
'exact'Search for exact matches. Note that when searchmethod is specified the search is case-sensitive.

[lat,lon] = extractm(display_struct) extracts all vector data from the input map structure.

[lat,lon,indx] = extractm(...) also returns the vector indx identifying which elements of display_struct met the selection criteria.

mat = extractm(...) returns the vector data in a single matrix, where mat = [lat lon].

Examples

Extract the District of Columbia from the low-resolution U.S. vector data:

   load greatlakes
   [lat, lon] = extractm(greatlakes, 'Erie');
   axesm mercator
   geoshow(lat,lon, 'DisplayType','polygon', 'FaceColor','blue')

Tips

A Version 1 display structure is a MATLAB® structure that can contain line, patch, text, regular data grid, geolocated data grid, and certain other objects and fixed attributes. In Mapping Toolbox Version 2, a new data structure for vector geodata was introduced (called a mapstruct or a geostruct, depending on whether coordinates it contains are projected or unprojected). Geostructs and mapstructs have few required fields and can include any number of user-defined fields, giving them much greater flexibility to represent vector geodata. For information about the contents and format of display structures, see Version 1 Display Structures in the reference page for displaym. For information about converting display structures to geographic data structures, see the reference page for updategeostruct, which performs such conversions.

Introduced before R2006a