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.

Get the geographic limits for an area of interest (AOI) surrounding Europe. Find the latitude and longitude limits of the AOI by using the bounds function.

europe = geocode("Europe");
[latlim,lonlim] = bounds(europe.Shape);

Using the limits of the AOI, read the layer as an array and a GeographicCellsReference object. The GeographicCellsReference object ties the map to a specific location on Earth.

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

Create an axesm-based map using the limits of the AOI. Display the layer on the map. Then, customize the map by removing the parallel and meridian labels.

figure
worldmap(latlim,lonlim)
geoshow(A,R)
plabel off
mlabel off

Add a title by specifying the layer title.

title(eox_update.LayerTitle)

See Also

Functions

Objects

Topics