Main Content


Update layer properties



[updatedLayer,index] = updateLayers(server,layer) returns an array of WMSLayer objects and updates the layer properties with values from the web map server, server. The WMSLayer array layer must contain only one unique ServerURL. The updateLayers function removes layers no longer available on the server. The logical array index contains true for each available layer.


collapse all

Update the properties of a MODIS global mosaic layer obtained from the NASA Earth Observations WMS server.

Search the WMS Database for the layer.

neo = wmsfind("neo*nasa","SearchFields","serverurl");
modis = refine(neo,"land*day*month");
modis = modis(1);

Create a web map server object by specifying the server URL of the layer.

server = WebMapServer(modis.ServerURL);

Update the properties of the layer by specifying the server and the layer.

updatedLayer = updateLayers(server,modis);

Read and display the map.

mapRequest = WMSMapRequest(updatedLayer,server);
A = getMap(server,mapRequest.RequestURL);
R = mapRequest.RasterReference;

ax = worldmap(A,R);
title(["MODIS Global Mosaic" modis.LayerTitle])

The layer used in this example is courtesy of the NASA Earth Observations System.

Search the WMS Database for layers from USGS servers that contain the word "imagery" in the server URL.

usgsLayers = wmsfind('usgs*imagery','SearchField','serverurl');

Create an array called updatedLayers. Use a loop to find the layers for individual servers, update the properties of the layers, and append the updated layers to the array. Display a message to the command line if a server does not respond.

updatedLayers = [];
serverURLs = usgsLayers.servers;

for k=1:numel(serverURLs)
   serverLayers = refine(usgsLayers, serverURLs{k}, ...
   serverURL = serverLayers(1).ServerURL;
   server = WebMapServer(serverURL);
      layers = updateLayers(server,serverLayers);
      % Grow using concatenation because layers can have any
      % length ranging from 0 to numel(serverLayers).
      updatedLayers = [updatedLayers; layers];
   catch e
       fprintf('Server %s is not responding.\n', ...
       fprintf('Error message is %s\n', e.message)

Input Arguments

collapse all

Web map server, specified as an array of WebMapServer objects.

Web map service layer, specified as a WMSLayer object.

Output Arguments

collapse all

Updated web map service layers, returned as an array of WMSLayer objects. updatedLayers has the same size as layer(index).

Availability of layers, returned as a logical array. index contains true for each available layer.


updateLayers accesses the Internet to update the properties. Occasionally, a WMS server is unavailable, or several minutes elapse before the properties are updated.

Version History

Introduced before R2006a