Documentation

updateLayers

Class: WebMapServer

Update layer properties

Syntax

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

Description

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

Examples

expand all

Update Properties of MODIS Global Mosaic Layer

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) 

Update Properties of Layers from Multiple Servers

Find layers from USGS servers with the word "geology" in the server URL.

 usgsLayers = wmsfind('usgs.gov*geology','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 
Updating layer properties from 16 servers.
Updating properties from server 1:
http://certmapper.cr.usgs.gov/arcgis/services/geology/afghanistan/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/afghanistan/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 2:
http://certmapper.cr.usgs.gov/arcgis/services/geology/africa/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/africa/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 3:
http://certmapper.cr.usgs.gov/arcgis/services/geology/arabian/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/arabian/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 4:
http://certmapper.cr.usgs.gov/arcgis/services/geology/arctic/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/arctic/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 5:
http://certmapper.cr.usgs.gov/arcgis/services/geology/asiapacific/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/asiapacific/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 6:
http://certmapper.cr.usgs.gov/arcgis/services/geology/bangladesh/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/bangladesh/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 7:
http://certmapper.cr.usgs.gov/arcgis/services/geology/caribbean/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/caribbean/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 8:
http://certmapper.cr.usgs.gov/arcgis/services/geology/europe/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/europe/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 9:
http://certmapper.cr.usgs.gov/arcgis/services/geology/formersovietunion/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/formersovietunion/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 10:
http://certmapper.cr.usgs.gov/arcgis/services/geology/gulfofmexico/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/gulfofmexico/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 11:
http://certmapper.cr.usgs.gov/arcgis/services/geology/iran/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/iran/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 12:
http://certmapper.cr.usgs.gov/arcgis/services/geology/southamerica/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/southamerica/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 13:
http://certmapper.cr.usgs.gov/arcgis/services/geology/southasia/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/southasia/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 14:
http://certmapper.cr.usgs.gov/arcgis/services/geology/wyoming/MapServer/WMSServer?
Server http://certmapper.cr.usgs.gov/arcgis/services/geology/wyoming/MapServer/WMSServer? is not responding.
Error message is The Capabilities file from the host 'certmapper.cr.usgs.gov' cannot be found.
Updating properties from server 15:
http://certmapper.cr.usgs.gov/arcgis/services/one_geology_wms/USGS_Geologic_Map_of_North_America/MapServer/WMSServer?
Updating properties from server 16:
http://certmapper.cr.usgs.gov/arcgis/services/one_geology_wms/USGS_Geologic_Map_of_North_America_GFI/MapServer/WMSServer?
Was this topic helpful?