Main Content

Basic Workflow for Creating WMS Maps

A Web Map Service (WMS) provides images of publicly accessible geospatial information from web-based sources. This example shows how to find and display a WMS map of satellite imagery for a region around Europe.

Search WMS Database

A layer is a data set that contains a specific type of geographic information, such as elevation, weather, or orthoimagery. Mapping Toolbox™ contains a database, called the WMS Database, that includes more than 100,000 layers from more than 1000 servers. You can search the WMS Database by using the wmsfind function. By default, the wmsfind function searches the WMS Database for matching layer names and layer titles.

For this example, search the WMS Database for layers that mention eox. For more information about EOX::Maps, see EOX::Maps.

eox = wmsfind("eox");

The wmsfind function returns layers as WMSLayer objects. In this case, the function returned multiple layers. Note that your results might be different because the WMS Database changes each release.

Refine Search

Refine your search based on the WMS Database by using the refine function or based on geographic limits by using the refineLimits function. If your original search provides only one layer, then you do not need to refine your search.

For this example, refine your search to find layers in the WMS Database that also contain blue marble imagery from the NASA Earth Observatory.

eox_marble = refine(eox,"blue marble");

In this case, there are multiple layers in the WMS Database from EOX::Maps that contain blue marble imagery. Refine your search again to find layers with valid latitude limits.

eox_marble_limits = refineLimits(eox_marble,"Latlim",[-90 90]);

The refined search includes one layer.

Synchronize Layer with Server

Get up-to-date information about the layer by synchronizing it with the web server. The wmsupdate function updates the properties of WMSLayer objects, including the Abstract, CoordRefSysCodes, and Details properties.

Update the layer.

eox_update = wmsupdate(eox_marble_limits);

Read and Display Map

Read the WMS map from the server by using the wmsread function. You can customize the map by specifying properties such as the geographic limits, image dimensions, and background color.

For this example, create an axesm-based map with geographic limits that are appropriate for Europe. Get the current map projection structure (mstruct), which contains properties of the current map.

figure
worldmap europe
mstruct = gcm;
latlim = mstruct.maplatlimit;
lonlim = mstruct.maplonlimit;

Read the layer as an array and a GeographicCellsReference object, which ties the map to a specific location on Earth. Specify the latitude and longitude limits as the current map limits.

[A,R] = wmsread(eox_update,"Latlim",latlim,"Lonlim",lonlim);

Display the map. Add a title by specifying the layer title.

geoshow(A,R)
title(eox_update.LayerTitle)
plabel off
mlabel off

See Also

Functions

Objects

Related Topics