Main Content


Synchronize WMSLayer object with server


[updatedLayers,index] = wmsupdate(layers) returns a Web Map Service (WMS) layer array with its properties synchronized with values from the server, where layers contains only one, unique ServerURL. wmsupdate removes layers that are no longer available on the server.

wmsupdate returns the logical array index which contains true for each available layer. Thus, the return value updatedLayers has the same size as layers(index). Except for deletion, updatedLayers preserves the same order of layers as layers.

[...] = wmsupdate(layers,Name,Value, ...) specifies parameter-value pairs that modify the request. Parameter names can be abbreviated and are case-insensitive.

The function accesses the Internet to update the properties. Periodically, the WMS server is unavailable. Updating the layer can take several minutes. The function times-out after 60 seconds if a connection is not made to the server.


collapse all

Search the WMS Database for specific layers from the NASA Goddard Space Flight Center DAAC servers. Then, synchronize the properties of the layers with values from the servers.

nasa = wmsfind('','SearchField','serverurl');
nasa = wmsupdate(nasa,'AllowMultipleServers',true);

When you synchronize WMS layers with the corresponding WMS server, the Abstract, CoordRefSysCodes, and Details properties of the WMSLayer objects become available. You can use the additional information to refine your search.

Find all layers in the WMS Database with the title 'Global Sea Surface Temperature'. Determine the number of unique servers by using the servers function.

global_sst = wmsfind ('Global Sea Surface Temperature', ...
ans = 1×1 cell array

Synchronize the layers with the server. View the abstract, coordinate reference system code, and details of the first layer.

global_sst = wmsupdate(global_sst);
ans = 
    'The temperature of the surface of the world's oceans provides a clear indication of the state of the Earth's climate and weather.  The AMSR-E instrument on the Aqua satellite measures the temperature of the top 1 millimeter of the ocean every day, even through the clouds.  In this visualization sequence covering the period from June, 2002, to September, 2003, the most obvious effects are the north-south movement of warm regions across the equator due to the seasonal movement of the sun and the seasonal advance and retreat of the sea ice near the North and South poles.  It is also possible to see the Gulf Stream, the warm river of water that parallels the east coast of the United States before heading towards northern Europe, in this data.  Around January 1, 2003, a cooler than normal region of the ocean appears just to the west of Peru as part of a La Nina and flows westward, driven by the trade winds.  The waves that appear on the edges of this cooler area are called tropical instability waves and can also be seen in the equatorial Atlantic Ocean about the same time.
     Additional Credit:
     B>Please give credit for this item to:</b><br />'

ans = 1×1 cell array

ans = struct with fields:
     MetadataURL: ''
      Attributes: [1×1 struct]
     BoundingBox: [1×1 struct]
       Dimension: [1×1 struct]
    ImageFormats: {'image/png'}
     ScaleLimits: [1×1 struct]
           Style: [1×2 struct]
         Version: '1.3.0'

Search for abstracts for layers that contain 'El Nino'.

el_nino = refine(global_sst,'El Nino', ...

Search the WMS database for layers from the NASA Goddard Space Flight Center SVS Image Server. Synchronize the properties of the layers with values from the server. Then, refine the search to find layers containing the term "blue marble".

gsfc = wmsfind('','SearchField','serverurl');
gsfc = wmsupdate(gsfc);
blue_marble = refine(gsfc,'blue marble','SearchField','abstract');

Further refine the search to find the first layer with a title containing the terms "512" and "image".

queryStr = '*512*image';
layers =  refine(blue_marble,queryStr);
layer = layers(1);

Display the layer.

[A,R] = wmsread(layer);
worldmap world
plabel off
mlabel off

Updating layers from multiple servers might take a long time. You can avoid updating layers multiple times by saving updated layers to a MAT file.

Search the WMS Database for server URLs that contain NOAA. Refine the search to include information about oceans.

layers = wmsfind('noaa','SearchFields','ServerURL');
layers = refine(layers,'ocean');

Update the layers. The code might take several minutes to run because it is synchronizing layers for multiple servers.

updatedLayers = wmsupdate(layers,'AllowMultipleServers',true);

Save the layers to a MAT file called oceanLayers.


In the future, you can load the MAT file, refine your search, and read a map without updating the layers again.

Note that servers change, so the layers contained in the MAT file might become out-of-date.

Input Arguments

collapse all

Updated layers, specified as an array of WMSLayer objects.

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Number of seconds to elapse before a server times out, specified as an integer-valued, scalar double. If you specify the value 0, wmsinfo ignores the time-out mechanism.

Data Types: double | int16 | int32 | int64 | int8 | single | uint8 | uint16 | uint32 | uint64

Layer array may contain elements from multiple servers, specified as true or false. The value false indicates the array must contain elements from the same server. Use caution when setting the value to true, since you are making a request to each unique server and each request can take several minutes to finish.

Data Types: double | int16 | int32 | int64 | int8 | single | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Synchronized layers, returned as an array of WMSLayer objects with its properties synchronized with values from the server.

Available layers, returned as a logical array where the value true indicates that the layer was available from the server.


  • To specify a proxy server to connect to the Internet, click Preferences and, in the Preferences dialog box, select Web. Enter your proxy information. Use this feature if you have a firewall. For more information, see Proxy Server Authentication.

  • Depending on the number or reliability of servers, you might have to wait several minutes for information to download. Servers can become unavailable.

Version History

Introduced in R2009b