Main Content

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

Search the WMS Database for all layers on NASA's Earth Observations (NEO) WMS server. Refine the search to include only layers with 'sea surface temperature' in the layer title or layer name fields of the WMS Database. Refine the search again to include only layers with monthly values from the MODIS sensor on the Aqua satellite.

neowms = wmsfind('neowms','SearchField','serverurl');
sst = refine(neowms,'sea surface temperature');
sst = refine(sst,'month*modis');

Create a WebMapServer object from the server URL stored in the ServerURL property of the WMSLayer object sst.

server = WebMapServer(sst(1).ServerURL);

Create a WebMapRequest object from the layer array and web map server object. Set the latitude and longitude limits by using the Latlim and Lonlim properties. Set the time request to March 1, 2009 by using the Time property.

mapRequest = WMSMapRequest(sst,server);
mapRequest.Latlim = [-45 -25];
mapRequest.Lonlim = [15 35];
mapRequest.Time = '2009-03-01';

Send your request to the server by using the getMap function.

sstImage = getMap(server,mapRequest.RequestURL);

Display the image on a map.

figure
worldmap(mapRequest.Latlim,mapRequest.Lonlim);
setm(gca,'mlabelparallel',-45)
geoshow(sstImage,mapRequest.RasterReference);
title({'South Africa',sst.LayerTitle}, ...
    'FontWeight','bold','Interpreter','none')

Manually Edit Web Map Request URL

You can modify a map request URL manually.

Search the WMS Database for layers containing the string 'nasa'. Refine the search to find layers containing Blue Marble: Next Generation by specifying the search string as 'bluemarbleng'. Get the map request URL for the first layer.

nasa = wmsfind('nasa','SearchField','serverurl');
layer = refine(nasa,'bluemarbleng','SearchField','layername', ...
   'MatchType','exact');
layer = layer(1);
mapRequest = WMSMapRequest(layer);

Set the map request URL to a variable.

mapURL = mapRequest.RequestURL;

Modify the bounding box to include the southern hemisphere. To do this, copy and paste the contents of mapURL into a new variable. Then, change the bounding box section of the URL to &BBOX=-180.0,-90.0,180.0,0.0.

modifiedURL = ['https://neo.sci.gsfc.nasa.gov/wms/wms?' ...
               '&SERVICE=WMS&LAYERS=BlueMarbleNG&CRS=CRS:84' ...
               '&FORMAT=image/jpeg&TRANSPARENT=FALSE' ...
               '&HEIGHT=256&BGCOLOR=0xFFFFFF&REQUEST=GetMap&WIDTH=512' ...
               '&BBOX=-180.0,-90.0,180.0,0.0' ...
               '&STYLES=&VERSION=1.3.0'];

Read and 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