Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

WMSMapRequest

Web Map Service map request

Description

A WMSMapRequest object contains a request to a WMS server to obtain a map, which represents geographic information. The WMS server renders the map as a color or grayscale image. The object contains properties that you can set to control the geographic extent, rendering, or size of the requested map.

Creation

You can

mapRequest = WMSMapRequest(layer)
mapRequest = WMSMapRequest(layer,server)

Description

mapRequest = WMSMapRequest(layer) creates a WMSMapRequest object, setting the Layer property. The WMSMapRequest object updates the properties of Layer, if necessary.

example

mapRequest = WMSMapRequest(layer,server) creates a WMSMapRequest object, setting the Layer and Server properties. The ServerURL property of layer must match the ServerURL property of server. The Server object updates Layer properties.

Properties

expand all

Web map server, specified as a scalar WebMapServer object. If a server is not supplied as an argument when creating the WMSMapRequest, the value of Server is set to the ServerURL of Layer.

Web Map Service layers, specified as an array of WMSLayer objects.

Layer contains one unique ServerURL, which must match the ServerURL property of Server. The Server property updates the properties of Layer when the property is set.

Coordinate reference system code, specified as the character vector 'CRS:84' for WMS version 1.3.x, and 'EPSG:4326' for all other versions.

  • If 'EPSG:4326' is not found in Layer.CoordRefSysCodes, then the CoordRefSysCode value is set from the first CoordRefSysCode found in the Layer.Details.BoundingBox structure array.

  • When CoordRefSysCode is set to 'EPSG:4326' or 'CRS:84', the XLim and YLim properties are set to [] and the Latlim and Lonlim properties are set to the geographic extent defined by the Layer array.

  • When CoordRefSysCode is set to a value other than 'EPSG:4326' or 'CRS:84', then the XLim and YLim properties are set from the values found in the Layer.Details.BoundingBox structure and the Latlim and Lonlim properties are set to [].

  • Automatic projections are not supported. (Automatic projections begin with 'AUTO'.)

Data Types: char

Map or geographic raster reference, specified as a MapCellsReference or GeographicCellsReference object. RasterReference references the raster map to an intrinsic coordinate system

Latitude limits, specified as a two-element vector. Latlim contains the southern and northern latitudinal limits of the request in units of degrees. The limits must be ascending. By default, the latitude limits span all latitudinal limits found in the Layer.Latlim property.

Longitude limits, specified as a two-element vector. Lonlim contains the western and eastern longitudinal limits of the request in units of degrees. The limits must be ascending and in the range [-180, 180] or [0, 360]. By default, the longitude limits span all longitudinal limits found in the Layer.Lonlim property.

Western and eastern limits of the requested map in the units of the coordinate reference system, specified as a two-element vector. The limits must be ascending. You can set XLim only if you set CoordRefSysCode to a value other than EPSG:4326.

Southern and northern limits of the requested map in the units of the coordinate reference system, specified as a two-element vector. The limits must be ascending. You can set YLim only if you set CoordRefSysCode to a value other than EPSG:4326.

Height in pixels for the requested raster map, specified as a positive integer. The property MaximumHeight defines the maximum value for ImageHeight. The WMSMapRequest object initializes the ImageHeight property to either 512 or to an integer value that best preserves the aspect ratio of the coordinate limits, without changing the coordinate limits.

Width in pixels for the requested raster map, specified as a positive integer. The property MaximumWidth defines the maximum value for ImageWidth. The WMSMapRequest object initializes the ImageWidth property to either 512 or to an integer value that best preserves the aspect ratio of the coordinate limits, without changing the coordinate limits.

This property is read-only.

Maximum height in pixels for the requested map, specified as the number 8192.

Data Types: double

This property is read-only.

Maximum width in pixels for the requested map, specified as the number 8192.

Data Types: double

Elevation extent of the requested map, specified as a character vector. When you set the property, 'elevation' must be the value of the Layer.Details.Dimension.Name field.

Time extent of the requested map, specified as a character vector or numeric scalar. See the WMSMapRequest.Time reference page for more information.

Data Types: double | char

Name and value of a sample dimension, specified as a two-element cell array of character vectors. The name cannot be 'time' or 'elevation'. SampleDimension{1} must be the value of the Layer.Details.Dimension.Name field.

Flag indicating transparency of map background, specified as a logical scalar. When you set Transparent to true, the server sets all pixels not representing features or data values in that layer to a transparent value, producing a composite map. When you set Transparent to false, the server sets all non-data pixels to the value of the background color.

Data Types: logical

Color of the background (non-data) pixels of the map, specified as a three-element numeric vector. The values range from 0 to 255. The default value, [255,255,255], specifies the background color as white. You can set BackgroundColor using non-uint8 numeric values, but they are cast and stored as uint8.

Data Types: uint8

Style to use when rendering the image, specified as a character vector or cell array of character vectors. The StyleName must be a valid entry in the Layer.Details.Style.Name field. The cell array of character vectors contains the same number of elements as does Layer.

Desired image format used to render the map as an image, specified as a character vector. If set, the format must match an entry in the Layer.Details.ImageFormats cell array and an entry in the ImageRenderFormats property. If not set, the format defaults to a value in the ImageRenderFormats property.

This property is read-only.

Preferred image rendering formats when Transparent is set to false, specified as a cell array. The first entry is the most preferred image format. If the preferred format is not stored in the Layer property, then the next format from the list is selected, until a format is found. The ImageRenderFormats array is not used if the ImageFormat property is set.

This property is read-only.

Preferred image rendering formats when Transparent is set to true, specified as a cell array. The first entry is the most preferred image format. If the preferred format is not stored in the Layer property, then the next format from the list is selected, until a format is found. If a transparent image format is not found in the list, or if the ImageFormat property is set to a non-default value, then ImageFormat is unchanged.

Server URL for the WMS GetMap request, specified as a character vector. In general, ServerURL matches the ServerURL of the Layer. However, some WMS servers, such as the Microsoft® TerraServer, require a different URL for GetMap requests than for WMS GetCapabilities requests. By default, ServerURL is Layer(1).ServerURL.

Data Types: char

This property is read-only.

Full URL for the WMS GetMap request, specified as a character vector. It is composed of the ServerURL with additional WMS parameter/value pairs.

Object Functions

boundImageSize Bound size of raster map

Examples

expand all

Read a global, half-degree resolution, sea-surface temperature map for the month of November 2009. The map, from the AMSR-E sensor on NASA's Aqua satellite, uses data provided by NASA's Earth Observations (NEO) WMS server.

sst = wmsfind('AMSRE_SSTAn_M');
server = WebMapServer(sst.ServerURL);
mapRequest = WMSMapRequest(sst, server);
timeRequest = '2009-11-01';
mapRequest.Time = timeRequest;
samplesPerInterval = .5;
mapRequest.ImageHeight = ...
   round(abs(diff(sst.Latlim))/samplesPerInterval);
mapRequest.ImageWidth = ...
   round(abs(diff(sst.Lonlim))/samplesPerInterval);
mapRequest.ImageFormat = 'image/png';
sstImage = server.getMap(mapRequest.RequestURL);

Read the legend for the layer using the OnlineResource URL field in the LegendURL structure. The legend shows that the temperature ranges from -2 to 35 degrees Celsius. The WMSMapRequest object updates the layer information from the server.

url = mapRequest.Layer.Details.Style(1).LegendURL.OnlineResource;
[legendImg,cmap] = imread(url);
if ~isempty(cmap)
   % Convert indexed image to RGB.
   legendRGB = ind2rgb(legendImg,cmap);
else
   % Already have an RGB image.
   legendRGB = legendImg;
end

Display the temperature map and legend.

fig = figure;
ax = worldmap('world');
setm(ax,'MlabelParallel',-90,'MlabelLocation',90)
    geoshow(sstImage,mapRequest.RasterReference);
    title({mapRequest.Layer.LayerTitle,timeRequest})

figurePosition = fig.Position;
centerWidth = figurePosition(3)/2;
axleft = centerWidth-size(legendImg,2)/2;
axbottom = 30;
axwidth  = size(legendRGB,2);
axheight = size(legendRGB,1);
axes('Units','pixels','Position',[axleft axbottom axwidth axheight])
image(legendRGB)
axis off

Read abstract information for this layer from the MetadataURL field.

options = weboptions('ContentType','xmldom','Timeout',10);
xml = webread(mapRequest.Layer.Details.MetadataURL,options);
abstract = xml.getElementsByTagName('abstract').item(0).getTextContent

Read and display a global elevation and bathymetry layer for the Gulf of Maine at 30 arc-seconds sampling interval. The values are in units of meters.

layers = wmsfind('srtm30', 'SearchField', 'LayerName');
layer = refine(layers,'data.worldwind','SearchField','serverurl')
server = WebMapServer(layer.ServerURL);
mapRequest = WMSMapRequest(layer,server);
mapRequest.Latlim = [40 46];
mapRequest.Lonlim = [-71 -65];
samplesPerInterval = 30/3600;
mapRequest.ImageHeight = ...
   round(abs(diff(mapRequest.Latlim))/samplesPerInterval);
mapRequest.ImageWidth = ...
   round(abs(diff(mapRequest.Lonlim))/samplesPerInterval);
mapRequest.ImageFormat = 'image/bil';
Z = getMap(server, mapRequest.RequestURL);

Display and contour the map at sea level (0 meters).

figure
worldmap(mapRequest.Latlim, mapRequest.Lonlim)
geoshow(double(Z),mapRequest.RasterReference,'DisplayType','texturemap')
demcmap(double(Z))
contourm(double(Z),mapRequest.RasterReference,[0 0],'Color','black')
colorbar
title ({'Gulf of Maine', mapRequest.Layer.LayerTitle}, ...
       'Interpreter', 'none', 'FontWeight', 'bold')

See Also

Functions

Using Objects

Introduced in R2009b

Was this topic helpful?