This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Class: WebMapServer

Update layer properties


[updatedLayer, index] = updateLayers(server,layer)


[updatedLayer, index] = updateLayers(server,layer) returns a WMSLayer array with properties updated with values from server, a WebMapServer object. The WMSLayer array Layer must contain only one unique ServerURL. The updateLayers method removes layers no longer available on the server. The logical array index contains true for each available layer, such that updatedLayers has the same size as layer(index).

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


expand 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;
ax = worldmap('world');
title({'MODIS Global Mosaic',modis.LayerTitle})

View the metadata of the layer.

metadata = webread(updatedLayer.Details.MetadataURL);

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', ...
for k=1:numel(serverURLs)
   serverLayers = refine(usgsLayers, serverURLs{k}, ...
   serverURL = serverLayers(1).ServerURL;
   fprintf('Updating properties from server %d:\n%s\n', ...
          k, 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)
Was this topic helpful?