Quantcast

Documentation Center

  • Trial Software
  • Product Updates

boundImageSize

Class: WMSMapRequest

Bound size of raster map

Syntax

mapRequest = boundImageSize(mapRequest, imageLength)

Description

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.

Examples

Read and display the VMAP0 basic layer for the entire globe. The rendered map has a spatial resolution of .5 degrees per cell and an image size of 360-by-720 pixels.

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

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

 

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.

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;
request = boundImageSize(request, 1024);
londonImage = getMap(request.Server, request.RequestURL);
figure;worldmap(londonImage, request.RasterRef);
geoshow(londonImage, request.RasterRef)
title({'Region Surrounding London, England', ...
    ['with Primary and Secondary Roads, ', ...
    'Rivers, Rails, City Label, and Basic Layers']})

Was this topic helpful?