Modify Your Map Request

Set Map Request Geographic Limits and Time

A WMSMapRequest object contains properties to modify the geographic extent and time of the requested map. This example demonstrates how to modify your map request to map sea surface temperature for the ocean surrounding the southern tip of Africa. For a complete list of properties, see WMSMapRequest.

  1. Search the WMS Database for all layers on NASA's Earth Observations (NEO) WMS server.

    neowms = wmsfind('neowms', 'SearchField', 'serverurl');
  2. Refine your search to include only layers with 'sea surface temperature' in the layer title or layer name fields of the WMS database.

    sst = neowms.refine('sea surface temperature');
    
  3. Refine your search to include only layers with monthly values from the MODIS sensor on the Aqua satellite.

    sst = sst.refine('month*modis');
    
  4. Construct a WebMapServer object from the server URL stored in the ServerURL property of the WMSLayer object sst.

    server = WebMapServer(sst(1).ServerURL);
    
  5. Construct a WebMapRequest object from a WMSLayer array and a WebMapServer object.

    mapRequest = WMSMapRequest(sst, server);
    
  6. Use the Latlim and Lonlim properties of WMSMapRequest to set the latitude and longitude limits.

    mapRequest.Latlim = [-45 -25];
    mapRequest.Lonlim = [15 35];
    
  7. Set the time request to March 1, 2009.

    mapRequest.Time = '2009-03-01';
    
  8. Send your request to the server with the WebMapServer.getMap method. Pass in a WMSMapRequest.RequestURL.

    sstImage = server.getMap(mapRequest.RequestURL);
    
  9. Set up empty map axes with the specified geographic limits.

    figure
    worldmap(mapRequest.Latlim, mapRequest.Lonlim);
    setm(gca, 'mlabelparallel', -45)
  10. Project and display an image georeferenced to latitude and longitude. Use the raster reference object provided by the RasterReference property of the WMSMapRequest object.

    geoshow(sstImage, mapRequest.RasterReference);
    title({'South Africa', sst.LayerTitle}, ...
        'FontWeight', 'bold', 'Interpreter', 'none')

Edit Web Map Request URL Manually

You can modify a map request URL manually.

  1. Obtain the map request URL.

    nasa = wmsfind('nasa', 'SearchField', 'serverurl');
    layer = nasa.refine('bluemarbleng', 'SearchField', 'layername', ...
       'MatchType', 'exact');
    layer = layer(1);
    mapRequest = WMSMapRequest(layer);
    
  2. View the map request URL by typing mapRequest.RequestURL at the command line.

    Sample Output:

    ans =
    
    http://neowms.sci.gsfc.nasa.gov/wms/wms?...
       SERVICE=WMS...
       &LAYERS=BlueMarbleNG...
       &EXCEPTIONS=application/vnd.ogc.se_xml...
       &FORMAT=image/jpeg...
       &TRANSPARENT=FALSE...
       &HEIGHT=256...
       &BGCOLOR=0xFFFFFF...
       &REQUEST=GetMap&WIDTH=512...
       &BBOX=-180.0,-90.0,180.0,90.0...
       &STYLES=&SRS=EPSG:4326...
       &VERSION=1.1.1
    
  3. Modify the bounding box to include the southern hemisphere by directly changing the mapRequest.RequestURL. Enter the following at the command line:

    modifiedURL = 

    Then enter the lengthy URL as shown in the previous code sample, but change the bounding box:

    &BBOX=-180.0,-90.0,180.0,0.0
    Enter the URL as one continuous character vector.

  4. Display the modified map.

    [A, R] = wmsread(modifiedURL);
    figure
    axesm globe
    axis off
    geoshow(A, R)
    title('Blue Marble: Southern Hemisphere Edition')
    

See Also

| |

Related Topics