WMSLayer

Web Map Service layer

Description

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

Creation

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.

Description

example

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.

Properties

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

Examples

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 = 'www.mrlc.gov'; 
path = '/geoserver/NLCD_Land_Cover/wms?'; 
serverURL = ['https://' host path]; 
requestURL = [serverURL 'SERVICE=WMS&FORMAT=image/jpeg&REQUEST=GetMap&' ... 
  'STYLES=&SRS=EPSG:4326&VERSION=1.1.1&LAYERS=mrlc_display:NLCD_2016_Land_Cover_L48&', ... 
  'WIDTH=1024&HEIGHT=470&BBOX=-128,23,-65,51']; 
layerName = 'mrlc_display:NLCD_2016_Land_Cover_L48';

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.

layer = wmsupdate(layer);
layer.Lonlim = [-180 180];

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, ... 
       'ImageHeight',height,'ImageWidth',width); 

Display the image from the server.

figure
usamap(A,R)
geoshow(A,R)
title('NLCD Land Cover')

This image can also be retrieved using the WMS requestURL.

[A,R] = wmsread(requestURL);
Introduced in R2009b