Main Content

boundImageSize

Bound size of raster map

Description

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.

example

Examples

collapse all

Read the capabilities document from the EOX::Maps server. For more information about EOX::Maps, see EOX::Maps. Extract the list of layers from the capabilities document.

info = wmsinfo("https://tiles.maps.eox.at/wms?");
eox = info.Layer;

Get a layer containing terrain data. Then, create a WMS map request from the layer. Update the map request to set all pixels that do not represent features or data values to a transparent value.

layer = refine(eox,"terrain-light",MatchType="exact");
request = WMSMapRequest(layer);
request.Transparent = true;

Set the bounds of the map request to 720 pixels. Then, use the map request to read an image from the server.

request = boundImageSize(request,720);
globalImage = getMap(request.Server,request.RequestURL);

Note that the width of the image is 720 pixels.

size(globalImage)
ans = 1×3

   360   720     3

Display the image on a 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
plabel off
mlabel off
geoshow(globalImage,request.RasterReference);
title(layer.LayerTitle)

Figure contains an axes object. The hidden axes object with title Terrain Light background layer by EOX - 4326 contains 4 objects of type patch, surface, line.

Read the capabilities document from the EOX::Maps server. For more information about EOX::Maps, see EOX::Maps. Extract the list of layers from the capabilities document.

info = wmsinfo("https://tiles.maps.eox.at/wms?");
eox = info.Layer;

Create an array of multiple layers that includes terrain, coastlines, and hydrography.

terrain = refine(eox,"terrain-light",MatchType="exact");
coast = refine(eox,"coastline_black",MatchType="exact");
hydro = refine(eox,"hydrography",MatchType="exact");

layers = [coast; hydro; terrain];

Create a WMS map request from the layer. Update the map request to set all pixels that do not represent features or data values to a transparent value.

request = WMSMapRequest(layers);
request.Transparent = true;

Set the latitude and longitude limits of the request to a region surrounding Dublin.

dublin = geocode("Dublin");

extent = [-0.25 0.25];
request.Latlim = dublin.Shape.Latitude + extent;
request.Lonlim = dublin.Shape.Longitude + extent;

Set the bounds of the map request to 1024 pixels. Then, use the map request to read an image from the server.

request = boundImageSize(request,1024);
dublin = getMap(request.Server,request.RequestURL);

Note that the height and width of the image are 1024 pixels.

size(dublin)
ans = 1×3

        1024        1024           3

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

figure
usamap(dublin,request.RasterReference)
geoshow(dublin,request.RasterReference)
title("Region Surrounding Dublin")
subtitle("Terrain, Hydrography, and Coastlines")

Figure contains an axes object. The hidden axes object with title Region Surrounding Dublin contains 14 objects of type patch, surface, line, text.

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