Main Content


Get raster map from server



A = getMap(server,mapRequestURL) dynamically renders and retrieves a color or grayscale, geographically referenced, raster map from the Web map services server, server, and stores it in A. Parameters in the URL, mapRequestURL, define the map. The getMap function also updates the RequestURL property of the server with mapRequestURL.

Most of the time, you can read a WMS map using wmsread function instead of the getMap function. Use the getMap function when:

  • Working with non-EPSG:4326 reference systems

  • Creating an animation of a specific geographic area over time

  • Retrieving multiple layers from a WMS server


collapse all

Search the WMS Database for a layer containing terrain elevation data from the WMS server hosted by MathWorks®.

layers = wmsfind("mathworks","SearchField","serverurl");
layer = refine(layers,"elevation");

Create a web map server object and a map request object. Change the background color of the map request to cyan.

server = WebMapServer(layer.ServerURL);
mapRequest = WMSMapRequest(layer,server);
mapRequest.BackgroundColor = [0 255 255];

Read the map from the server.

A = getMap(server,mapRequest.RequestURL);
R = mapRequest.RasterReference;

Display the map.

worldmap world
plabel off
mlabel off

Input Arguments

collapse all

Web map server, specified as a WebMapServer object.

URL, specified as a character vector. Parameters in the URL define the map.

You can get a URL from:

  • The output of wmsread

  • The RequestURL property of a WMSMapRequest object

  • An Internet search

Output Arguments

collapse all

Rendered map, returned as a color or grayscale image.


getMap accesses the Internet to retrieve the map. Periodically, the WMS server is unavailable. Retrieving the map can take several minutes.

Version History

Introduced before R2006a