WMSLayer class

Web Map Service layer object


A WMSLayer object describes a Web Map Service (WMS) layer or layers. Obtain a WMSLayer object by using wmsfind or wmsinfo. The function wmsfind returns a WMSLayer array. The function wmsinfo returns a WMSCapabilities object, which contains a WMSLayer array in its Layer property.


layers = WMSLayer(param, val, ...) constructs a WMSLayer object from the input parameter names and values. If a parameter name matches a property name of the WMSLayer class (ServerTitle, ServerURL, LayerTitle, LayerName, Latlim, Lonlim, Abstract, CoordRefSysCodes, or Details) then the values of the parameter are copied to the property. 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.


You can only set the 'Latlim' and 'Lonlim' properties, which have public set access.


Descriptive information about the server

Data Type: string

Default: ''


The URL of the server

Data Type: string

Default: ''


Descriptive information about the layer; clarifies the meaning of the raster values of the layer

Data Type: string

Default: ''


The keyword the server uses to retrieve the layer

Data Type: string

Default: ''


The southern and northern latitude limits of the layer in units of degrees and in the range [-90, 90].

Data Type: two-element vector

Default: []


The western and eastern longitude limits of the layer in units of degrees. The limits must be ascending and in the range [-180, 180] or [0 360].

Data Type: two-element vector

Default: []


Information about the layer

Data Type: string

Default: ''


String codes of available coordinate reference systems

Data Type: cell array

Default: {}


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

Data Type: structure


dispDisplay properties
refineRefine search
refineLimitsRefine search based on geographic limits
serversReturn URLs of unique servers
serverTitlesReturn titles of unique servers


Construct a WMSLayer object from a WMS GetMap request URL:

serverURL = ['' ...
requestURL = [serverURL 'SERVICE=WMS&FORMAT=image/jpeg&' ...
    'REQUEST=GetMap&' ...
    'STYLES=&SRS=EPSG:4326&VERSION=1.1.1&', ...
    'LAYERS=NLCD_2001_Land_Cover&', ...
    'WIDTH=1024&HEIGHT=470&' ...

% Construct the WMSLayer object by using the serverURL
% variable and the value of the WMS LAYERS parameter.
% Update the remaining information from the server.
layer = WMSLayer('ServerURL', serverURL, ...
    'LayerName', 'NLCD_2001_Land_Cover');
layer = wmsupdate(layer)

% Request the layer from the server using the WMS request 
% parameters found in the requestURL string. Copy the WMS
% BBOX information to the latlim and lonlim parameters.
% Copy the WMS WIDTH and HEIGHT values to the ImageWidth and
% ImageHeight parameters.
lonlim = [-128, -65];
latlim = [23, 51];
[A, R] = wmsread(layer, 'Latlim', latlim, 'Lonlim', lonlim, ...
    'ImageHeight', 470 , 'ImageWidth', 1024);

% Display the rendered image.
usamap(A, R)
geoshow(A, R)
title(layer.LayerTitle, 'Interpreter', 'none')

% The image can also be retrieved using the requestURL.
[A, R] = wmsread(requestURL);

Was this topic helpful?