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 elevation data 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 etopo1. ETOPO1 is a 1-minute model of global land topography and ocean bathymetry data.

etopo1 = wmsfind("etopo1");

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 mention hillshade.

etopo1_hill = refine(etopo1,"hillshade");

In this case, there are multiple layers in the WMS Database that mention both etopo1 and hillshade. Refine your search again to find layers on government servers.

etopo1_hill_gov = refine(etopo1_hill,".gov","SearchFields","ServerURL");

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.

etopo1_update = wmsupdate(etopo1_hill_gov);

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 map axes with geographic limits that are appropriate for Europe. Get the current map projection structure (mstruct), which contains properties of the current map axes.

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 axes limits.

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

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


See Also



Related Topics