[+] Help >> Use ORNL DAAC WMS Service in Matlab

Use ORNL DAAC WMS Service in Matlab

Required Matlab Plug-in

Usage Examples


Required Matlab Plug-in

Mapping Toolbox

Mapping Toolbox™ provides tools and utilities for analyzing geographic data and creating map displays. You can import vector and raster data from shapefile, GeoTIFF, SDTS DEM, and other file formats, as well as Web-based data from Web Map Service (WMS) servers. The toolbox lets you customize the imported data by subsetting, trimming, intersecting, adjusting spatial resolution, and applying other methods. Geographic data can be combined with base map layers from multiple sources in a single map display. With function-level access to all key features, you can automate frequent tasks in your geospatial workflow.

For more information: http://www.mathworks.com/help/map/index.html


Usage Examples

Connect to ORNL DAAC WMS service and retrieve its capabilities:

>> server_url = 'http://webmap.ornl.gov/ogcbroker/wms';
>> server = WebMapServer(server_url);
>> capabilities = wmsinfo(server_url);
>> capabilities
capabilities =

  WMSCapabilities

  Properties:
         ServerTitle: 'ORNL DAAC WMS Server'
           ServerURL: 'http://webmap.ornl.gov/ogcbroker/wms'
         ServiceName: 'OGC:WMS'
             Version: '1.1.1'
            Abstract: 'The ORNL DAAC provides access to various geospatial data, including ORNL DAAC archived data through Open Geospatial Consortium (OGC) standards-based Web Map Service (WMS) version 1.1.1.'
      OnlineResource: 'http://webmap.ornl.gov/ogcbroker/wms?'
  ContactInformation: [1x1 struct]
   AccessConstraints: ''
                Fees: ''
         KeywordList: {'WMS' 'ORNL' 'DAAC'}
        ImageFormats: {7x1 cell}
          LayerNames: {5142x1 cell}
               Layer: [5142x1 WMSLayer]
          AccessDate: '29-Mar-2013'

  Methods


List available layers and search layer by keywords:

% list all available layers
>> capabilities.Layers
...
...

% search layers with keywords "amazon rain 1972" in title
>> results=capabilities.Layers.refine('amazon*rain*1972', 'SearchFields', 'LayerTitle');
>> results
results =

  WMSLayer

  Properties:
           Index: 1
     ServerTitle: 'ORNL DAAC WMS Server'
       ServerURL: 'http://webmap.ornl.gov/ogcbroker/wms'
      LayerTitle: 'Amazon Rain fall 1972 (All months)'
       LayerName: '228_1'
          Latlim: [-20.0000 5.2000]
          Lonlim: [-79.6000 -49.4000]
        Abstract: ''
CoordRefSysCodes: {'EPSG:4326'}
         Details: [1x1 struct]

  Methods

% show available time steps of found layer
>> rain = results(1);
>> rain.Details.Dimension.Name
ans =

time
>> rain.Details.Dimension.Extent
ans =

1972-01/1972-12/P1M


Get map of Amazon rain fall in June, 1972:

% construct a WMS request with default parameters
>> request=WMSMapRequest([rain], server);

% set time step
>> request.Time = '1972-06';

% set image format
>> request.ImageFormat = 'image/png';

% send request to ORNL DAAC WMS
>> A=server.getMap(request.RequestURL);


Display requested map in a figure

% get map dimension
>> R=request.RasterRef;

>> figure;
% render background map
>> worldmap(A, R);

% render Amazon rain fall map in June, 1972
>> geoshow(A, R);

% add map title
>> title({rain.LayerTitle, request.Time});

% result


Fig. 1: Amazon Rain fall (1972-06)


Request and display map legend

% request map legend
>> legend_url = rain.Details.Style(1).LegendURL.OnlineResource;
>> legend_url
legend_url =

http://webmap.ornl.gov/ogcbroker/wms?version=1.1.1&service=WMS&request=GetLegendGraphic&layer=228_1&format=image/png&STYLE=default

% alpha is required here to deal with transparent PNG image
>> [legend, cmap, alpha] = imread(legend_url);

% display map legend image
>> figure;
>> image(legend);

% result


Fig. 2: Legend of Amazon Rain fall (1972-06)