Main Content

boundImageSize

Bound size of raster map

Description

example

mapBound = boundImageSize(mapRequest,imageLength) sets the bounds of the raster map mapRequest based on imageLength, the length in pixels for the row (ImageHeight) or column (ImageWidth) dimension.

Examples

collapse all

Read the VMAP0 basic layer for the entire globe.

info = wmsinfo('http://vmap0.tiles.osgeo.org/wms/vmap0');
vmap0 = info.Layer;
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 0.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'])

The data used in this example is from Metacarta.

Read multiple layers centered around London.

info = wmsinfo('http://vmap0.tiles.osgeo.org/wms/vmap0');
vmap0 = info.Layer;
layers = [refine(vmap0, 'rail'); refine(vmap0, 'river'); ...
       refine(vmap0, 'priroad'); refine(vmap0, 'secroad'); ...
       refine(vmap0, 'ctylabel'); refine(vmap0, 'basic')];
request = WMSMapRequest(layers);

cities = readgeotable('worldcities.shp');
row = cities.Name == 'London';
london = cities(row,:);

extent = [-.25 .25];
request.Latlim = london.Shape.Latitude + extent;
request.Lonlim = london.Shape.Longitude + 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 0.5 degrees and an image size of 1024-by-1024 pixels.

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

The data used in this example is from Metacarta.

Input Arguments

collapse all

Original Web map service map, specified as a WMSMapRequest object.

Row or column length of input WMS map, specified as a positive scalar. imageLength indicates the length in pixels for the row (ImageHeight) or column (ImageWidth) dimension.

Example: 720

Data Types: double

Output Arguments

collapse all

Bound Web map service map, returned as a WMSMapRequest object.

Algorithms

The boundImageSize function 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 of , if they are set.

boundImageSize measures image dimensions in geographic or map coordinates. The function 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.

Version History

Introduced in R2009b