Basic Workflow for Creating WMS Maps

Workflow Summary

  1. Search WMS Database.

  2. Refine search.

  3. Update layer.

  4. Modify request.

  5. Retrieve map.

  6. Display map.

Creating a Map of Elevation in Europe

Follow the example to learn the basic steps in creating a WMS map.

  1. Search the local WMS Database for a layer. WMS servers store map data in units called layers. Search for elevation layers.

    elevation = wmsfind('elevation');

    wmsfind returns an array of hundreds of WMSLayer objects.

  2. Refine your search. GTOPO30 is a digital elevation model developed by the United States Geological Survey (USGS). Refine your search to include only the layer with the exact name, ‘Foundation.GTOPO30' in the LayerName field.

    gtopolayer = refine(elevation, 'Foundation.GTOPO30', ...
                       'SearchField', 'layername', 'Match', 'exact');
    gtopolayer = refine(gtopolayer, '', 'SearchField', 'serverurl');
  3. Update your layer. You can skip this optional step for this example. The wmsupdate function accomplishes two tasks:

    • Updates your WMSLayer object to include the most recent data

    • Fills in its Details, CoordRefSysCodes, and Abstract fields

  4. Modify your request. Specify geographic limits, image dimensions, background color, and other properties of the map. In this simple example, modify only the background color. Choose red, green, and blue levels to define an ocean color.

    oceanColor = [0 170 255];
  5. Retrieve your map.

    First, set up a map axes with projection and geographic limits appropriate for Europe.

    worldmap europe;

    Then, return the map axes map structure, which contains the settings for all the current map axes properties.

    mstruct = gcm;

    Use the WMSLayer object gtopolayer as input for wmsread. Set the wmsread longitude and latitude limit parameters to the current map axes limits. Set the BackgroundColor parameter to oceanColor.

    [elevationImage, R] = wmsread(gtopolayer, 'Latlim', ...
       mstruct.maplatlimit, 'Lonlim', mstruct.maplonlimit, ...
       'BackgroundColor', oceanColor);

    The wmsread function returns a map called elevationImage and a referencing matrix R, which ties the map to a specific location on Earth.

  6. Display Vector Data as Points and Lines.

    geoshow(elevationImage, R);
    title({'Europe','Elevation'}, 'FontWeight', 'bold')

Was this topic helpful?