updateLayers

Update layer properties

Description

example

[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.

Examples

collapse all

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

nasa = wmsfind('NASA Earth Observations','SearchField','any');
modis = refine(nasa,'land*day*month');
modis = modis(1);

Create a WebMapServer object.

server = WebMapServer(modis.ServerURL);

Update the properties of the MODIS layer.

updatedLayer = updateLayers(server,modis);

Obtain the map and display it.

mapRequest = WMSMapRequest(updatedLayer,server);
A = getMap(server,mapRequest.RequestURL);
R = mapRequest.RasterReference;
figure
ax = worldmap('world');
geoshow(A,R)
setm(ax,'MLabelParallel',-90,'MLabelLocation',90)
title({'MODIS Global Mosaic',modis.LayerTitle})

View the metadata of the layer.

metadata = webread(updatedLayer.Details.MetadataURL);
disp(metadata) 

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

Find layers from USGS servers with the word “image” in the server URL.

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

Find the layers for an individual server, update their properties, and append them to the updatedLayers array.

serverURLs = usgsLayers.servers;
updatedLayers = [];
fprintf('Updating layer properties from %d servers.\n', ...
       numel(serverURLs));
for k=1:numel(serverURLs)
   serverLayers = refine(usgsLayers, serverURLs{k}, ...
          'SearchField','serverurl','MatchType','exact');
   serverURL = serverLayers(1).ServerURL;
   fprintf('Updating properties from server %d:\n%s\n', ...
          k, serverURL);
   server = WebMapServer(serverURL);
   try
      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', ...
              serverURL);
       fprintf('Error message is %s\n', e.message)
    end
end 

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.

Tips

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

Introduced before R2006a