Main Content

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

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.

example

Properties

expand all

This property is read-only.

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

Data Types: char

This property is read-only.

URL of WMS Server, returned as a character vector.

Data Types: char

This property is read-only.

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

Data Types: char

This property is read-only.

Keyword the server uses to retrieve the layer, returned 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

This property is read-only.

Information about the layer, returned as a character vector.

Data Types: char

This property is read-only.

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

Data Types: cell

This property is read-only.

Detailed information about the layer, returned as a structure containing these fields:

FieldDescription
MetadataURL

URL containing metadata information about the layer, returned as a character vector.

Attributes

Attributes of the layer, returned as a structure array containing these fields.

  • Queryable — Logical 1 (true) when you can query the layer for feature information, and logical 0 (false) otherwise.

  • Cascaded — Number of times a Cascading Map server has retransmitted the layer, returned as a double value.

  • Opaque — Logical 1 (true) when the map data is mostly or completely opaque, and logical 0 (false) otherwise.

  • NoSubsets — Logical 1 (true) when the map must contain the full bounding box, and logical 0 (false) when the map can be a subset of the full bounding box.

  • FixedWidth — Logical 1 (true) when the map has a fixed width that the server cannot change, and logical 0 (false) when the server can resize the map to an arbitrary width.

  • FixedHeight — Logical 1 (true) when the map has a fixed height that the server cannot change, and logical 0 (false) when the server can resize the map to an arbitrary height.

BoundingBox

Bounding box of the layer, returned as a structure array containing these fields.

  • CoordRefSysCode — Code number for the coordinate reference system, returned as a character vector.

  • XLimx-limits of the layer in units of the coordinate reference system, returned as a double array.

  • YLimy-limits of the layer in units of the coordinate reference system, returned as a double array.

Dimension

Dimension parameters, returned as a structure array containing these fields. Examples of dimensions include time, elevation, and temperature.

  • Name — Name of the dimension, returned as a character vector.

  • Units — Measurement unit for the dimension, returned as a character vector.

  • UnitSymbol — Symbol for the measurement unit, returned as a character vector.

  • Extent — Dimension values, returned as a character vector in one of these forms.

    • 'v' — A single value, for example '2002-01-01'.

    • 'v1,v2,...,vN' — A list of values, for example '2002-01-01,2002-02-01,2002-03-01'.

    • 'min/max/res' — An interval defined by the minimum and maximum bounds min and max, respectively, and the resolution res, for example '2002-01-01/2002-12-31/P1D'.

    • 'min1/max1/res1,min2/max2/res2,...,minN/maxN/resN' — A list of intervals, for example '2002-01-01/2002-12-31/P1D,2003-01-01/2003-12-31/P1D,2004-01-01/2004-12-31/P1D'.

  • Default — Default dimension value for the wmsread function to use, returned as a character vector. For example, when the value of Name is 'time', by default, the wmsread function reads data from the layer using the time contained in this field. To read data from the layer using a different time, use wmsread and specify the Time name-value argument.

  • MultipleValues — Logical 1 (true) if you can request dimension values, and logical 0 (false) if you can request only one value.

  • NearestValue — Logical 1 (true) if the server returns the nearest dimension value in response to a request for a nearby value, and logical 0 (false) if the value must match a value in the Extent field.

  • Current — Logical 1 (true) if the temporal data is kept current, and logical 0 (false) otherwise. This field is valid for temporal extents only.

ImageFormats

Image formats supported by the server, returned as a cell array of character vectors.

ScaleLimits

Scale limits of the layer, returned as a structure containing these fields.

  • ScaleHint — Minimum and maximum values that are appropriate for displaying the layer, returned as a double array. These values express the scale as ground distance, in meters, represented by the diagonal of the central pixel in the image.

  • MinScaleDenominator — Minimum scale denominator of maps for which a layer is appropriate, returned as a double value.

  • MaxScaleDenominator — Maximum scale denominator of maps for which a layer is appropriate, returned as a double value.

Style

Style parameters that determine layer rendering, returned as a structure array containing these fields.

  • Title — Descriptive title of the style, returned as a character vector.

  • Name — Name of the style, returned as a character vector.

  • Abstract — Information about the style, returned as a character vector.

  • LegendURL — Information about the legend graphics, returned as a structure containing these fields.

    • OnlineResource — URL of the legend graphics, returned as a character vector.

    • Format — Format of the legend graphics, returned as a character vector.

    • Height — Height of the legend graphics, returned as a double value.

    • Width — Width of the legend graphics, returned as a double value.

Version

WMS version specification, returned as a character vector.

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 URL of a WMS server. You can typically find the host and path components of the URL via an internet search.

host = "www.mrlc.gov"; 
path = "/geoserver/NLCD_Land_Cover/wms?"; 
serverURL = "https://" + host + path; 

Specify the name of the layer. You can typically find the name of a layer via an internet search.

layerName = "mrlc_display:NLCD_2016_Land_Cover_L48";

Create the WMS layer from the URL of the WMS server and the layer name.

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

Synchronize the layer with the server by using the wmsupdate function. Valid WMS layers have longitude limits in the range [–180, 180] or [0, 360]. Specify valid longitude limits for the layer by changing the Lonlim property.

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

Read an image from the WMS server by using the wmsread function. Specify the latitude and longitude limits using the Latlim and Lonlim name-value arguments. Specify the height and width of the image using the ImageHeight and ImageWidth name-value arguments.

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

Figure contains an axes object. The hidden axes object with title NLCD Land Cover contains 13 objects of type patch, surface, line, text.

You can also read the image by specifying a WMS GetMap request URL. Note that the URL contains the layer name in the LAYERS parameter, the latitude and longitude limits in the BBOX parameter, and the size of the image in the WIDTH and HEIGHT parameters.

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"; 
[A,R] = wmsread(requestURL);

Version History

Introduced in R2009b