Class: WMSMapRequest

Bound size of raster map


mapRequest = boundImageSize(mapRequest, imageLength)


mapRequest = boundImageSize(mapRequest, imageLength) bounds the size of the raster map based on the scalar imageLength. The scalar mapRequest is a WMSMapRequest object. The double imageLength indicates the length in pixels for the row (ImageHeight) or column (ImageWidth) dimension. The boundImageSize method calculates the row or column dimension length by using the aspect ratio of the Latlim and Lonlim properties or the aspect ratio of the XLim and YLim properties, if they are set.

The boundImageSize method measures image dimensions in geographic or map coordinates. The method sets the longest image dimension to imageLength, and the shortest to the nearest integer value that preserves the aspect ratio, without changing the coordinate limits. The maximum value of the MaximumHeight and MaximumWidth properties becomes the maximum value of imageLength.


expand all

Read and Display VMAP0 Basic Layer for Entire Globe

Read the VMAP0 basic layer for the entire globe.

vmap0 = wmsfind('vmap0.tiles','SearchField','serverurl');
vmap0 = wmsupdate(vmap0);
layer = refine(vmap0,'basic');
request = WMSMapRequest(layer);
request.Transparent = true;
imageLength = 720;
request = boundImageSize(request,imageLength);
globalImage = getMap(request.Server, request.RequestURL);

Display the map. The rendered map has a spatial resolution of .5 degrees per cell and an image size of 360-by-720 pixels.

figure; worldmap('world')
geoshow(globalImage, request.RasterReference);
title(['VMAP0 ' layer.LayerTitle ' Layer'])

Read and Display Multiple Layers Centered Around London

Read and display multiple layers centered around London. The rendered map has a spatial extent of .5 degrees and an image size of 1024-by-1024 pixels

vmap0 = wmsfind('vmap0.tiles','SearchField','serverurl');
vmap0 = wmsupdate(vmap0);
layers = [ refine(vmap0, 'rail'); refine(vmap0, 'river'); ...
       refine(vmap0, 'priroad'); refine(vmap0, 'secroad'); ...
       refine(vmap0, 'ctylabel'); refine(vmap0, 'basic')];
request = WMSMapRequest(layers);
cities = shaperead('worldcities', 'UseGeo', true);
london = cities(strcmpi('London', {cities.Name}));
extent = [-.25 .25];
request.Latlim = london.Lat + extent;
request.Lonlim = london.Lon + extent;
request.Transparent = true;
imageLength = 1024;
request = boundImageSize(request,imageLength);
londonImage = getMap(request.Server,request.RequestURL);

Display the map. The rendered map has a spatial extent of .5 degrees and an image size of 1024-by-1024 pixels

title({'Region Surrounding London, England', ...
   ['with Primary and Secondary Roads, ', ...
    'Rivers, Rails, City Label, and Basic Layers']})

Was this topic helpful?