Exploring Other Layers from a Server

You may find a layer you like in the WMS Database and then want to find other layers on the same server.

  1. Use the wmsinfo function to return the contents of the capabilities document as a WMSCapabilities object. A capabilities document is an XML document containing metadata describing the geographic content offered by a server.

    serverURL = 'http://webapps.datafed.net/AQS_H.ogc?';
    capabilities = wmsinfo(serverURL);
    
  2. View the layer names.

    capabilities.LayerNames
    

    Sample Output:

    ans = 
    
        'CO'
        'NO2'
        'NOX'
        'NOY'
        'O3'
        'SO2'
        'pm10'
  3. Read the Carbon Monoxide ('CO') layer.

    layer = capabilities.Layer.refine('CO');
    [A,R] = wmsread(layer,'cellsize',.1,'ImageFormat','image/png');
  4. Set the longitude and latitude limits to the values specified for the layer.

    latlim = layer.Latlim;
    lonlim = layer.Lonlim;
    
  5. Display the map.

    figure
    usamap(layer.Latlim, layer.Lonlim)
    geoshow(A,R)
    geoshow('usastatehi.shp','FaceColor','none','EdgeColor','black')
    title(layer.LayerTitle)

  6. Examine the Style field. (Open layer and then Details and then Style.) There are two structures. The style of the first one is set to 'data'. Read the layer again with the StyleName set to 'data' and the cell size set to 0.1 degree resolution. (When the style is set to 'data', the map does not include a legend.)

    [A,R] = wmsread(layer,'cellsize',.1, ...
      'ImageFormat','image/png','StyleName','data');
    figure
    usamap(layer.Latlim, layer.Lonlim)
    geoshow(A,R)
    geoshow('usastatehi.shp','FaceColor','none','EdgeColor','black')
    title(layer.LayerTitle)

Was this topic helpful?