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
.
Search the WMS Database for all layers on NASA's Earth Observations (NEO) WMS server.
neowms = wmsfind('neowms', 'SearchField', 'serverurl');
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');
Refine your search to include only layers with monthly values from the MODIS sensor on the Aqua satellite.
sst = sst.refine('month*modis');
Construct a WebMapServer
object from the server URL
stored in the ServerURL
property of the
WMSLayer
object sst
.
server = WebMapServer(sst(1).ServerURL);
Construct a WebMapRequest
object from a
WMSLayer
array and a WebMapServer
object.
mapRequest = WMSMapRequest(sst, server);
Use the Latlim
and Lonlim
properties
of WMSMapRequest
to set the latitude and longitude
limits.
mapRequest.Latlim = [-45 -25]; mapRequest.Lonlim = [15 35];
Set the time request to March 1, 2009.
mapRequest.Time = '2009-03-01';
Send your request to the server with the
WebMapServer.getMap
method. Pass in a
WMSMapRequest.RequestURL
.
sstImage = server.getMap(mapRequest.RequestURL);
Set up empty map axes with the specified geographic limits.
figure
worldmap(mapRequest.Latlim, mapRequest.Lonlim);
setm(gca, 'mlabelparallel', -45)
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')
You can modify a map request URL manually.
Obtain the map request URL.
nasa = wmsfind('nasa', 'SearchField', 'serverurl'); layer = nasa.refine('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,
create a new variable called modifiedURL
by copying and
pasting the contents of mapURL
. Then, change the bounding
box section of the URL to:
&BBOX=-180.0,-90.0,180.0,0.0
Enter the URL as one continuous character vector.
Display the modified map.
[A, R] = wmsread(modifiedURL); figure axesm globe axis off geoshow(A, R) title('Blue Marble: Southern Hemisphere Edition')
The image is courtesy of NASA/JPL-Caltech.