This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Web Map Service layer


A WMSLayer object describes a Web Map Service (WMS) layer or layers.


You can create a WMSLayer object using any of the following methods:

  • wmsfind — Returns a WMSLayer array.

  • wmsinfo — Returns a WMSCapabilities object, which contains an array of WMSLayer objects in its Layer property.

  • The WMSLayer object creation function, described here.

layers = WMSLayer(Name,Value,...)



layers = WMSLayer(Name,Value,...) constructs a WMSLayer object, where Name is the name of any property of the WMSLayer and Value is the value that you want to assign to the property. You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN. The size of the output layers is scalar unless all inputs are cell arrays, in which case, the size of layers matches the size of the cell arrays.


expand all

Descriptive information about the server, specified as a character vector.

Data Types: char

URL of WMS Server, specified as a character vector.

Data Types: char

Descriptive information about the layer, specified as a character vector. The LayerTitle clarifies the meaning of the raster values of the layer.

Data Types: char

Keyword the server uses to retrieve the layer, specified as a character vector.

Data Types: char

Latitude limits of the layer in units of degrees, specified as a two-element numeric vector. The limits specify the southern and northern latitude limits and must be in units of degrees and in the range [-90, 90].

Data Types: double

Longitude limits of the layer in units of degrees, specified as a two-element numeric vector. The limits specify the western and eastern longitude limits and must be ascending and in the range [-180, 180] or [0, 360].

Data Types: double

Information about the layer, specified as a character vector.

Data Types: char

Codes identifying available coordinate reference systems, specified as a cell array of character vectors.

Data Types: cell

Detailed information about the layer, specified as a structure containing: MetadataURL, Attributes, Scale, Dimension, Style. See the WMSLayer.Details reference page for more information.

Data Types: struct

Object Functions

disp Display properties of WMS layers or capabilities
refineRefine search of WMS layers
refineLimits Refine search of WMS layers based on geographic limits
servers Return URLs of unique WMS servers
serverTitles Return titles of unique WMS servers


collapse all

Specify the server URL. These values are typically found during an Internet search. The WMSLayer ServerURL value is obtained from the host and path of the request URL. The WMSLayer LayerName value is obtained from the LAYERS value in the query part of the URL.

host = ''; 
path = '/arcgis/services/NLCD/USGS_EDC_LandCover_NLCD/MapServer/WMSServer?'; 
serverURL = ['https://' host path]; 
requestURL = [serverURL 'SERVICE=WMS&FORMAT=image/jpeg&REQUEST=GetMap&' ...
     'STYLES=&SRS=EPSG:4326&VERSION=1.1.1&LAYERS=NLCD_2011_Land_Cover&', ... 
layerName = 'NLCD_2011_Land_Cover';

Construct the WMSLayer object by using the serverURL variable and the value of the WMS LAYERS parameter.

layer = WMSLayer('ServerURL', serverURL,'LayerName',layerName);

Use the wmsupdate function to get the other properties of the WMSLayer array from the server. The National Map Server may be busy, so try several times.

updatedLayer = wmsupdate(layer); 
if isempty(updatedLayer) 
    numAttempts = 1; 
    maxAttempts = 10; 
    delay = 1; 
    while isempty(updatedLayer) && numAttempts < maxAttempts 
          updatedLayer = wmsupdate(layer); 
          numAttempts = numAttempts + 1; 
layer = updatedLayer; 

Retrieve an image from the WMS server using layer and parameter values from the WMS GetMap request URL. Set latitude and longitude limits from the BBOX request value. Set image height and width values from the WIDTH and HEIGHT request values.

lonlim = [-128 -65];
latlim = [23 51]; 
height = 470; 
width = 1024; 
[A, R] = wmsread(layer,'Latlim',latlim,'Lonlim',lonlim, ... 

Display the image from the server.

usamap(A, R)
geoshow(A, R)
title(layer.LayerTitle, 'Interpreter', 'none')

The image can also be retrieved using the WMS requestURL.

[A, R] = wmsread(requestURL);

Introduced in R2009b